Sunday, April 24, 2016

K-Means from Scratch

by David Lettier


Using plain vanilla JavaScript, we built the K-Means algorithm from scratch as well as the silhouette coefficient metric. We discussed different mean initialization techniques and went into depth about Fouad Kahn’s approach. The assignment and update steps were discussed where the data-points are assigned to their closest means and the means are updated by averaging the features of their currently assigned data-points. To not lock up our interface we used requestAnimationFrame and cycled our iterations for both K-Means and the silhouette coefficient metric. Lastly, we discussed one way of determining how well our data is clustered using the silhouette coefficient metric and went over some unintuitive cases.

Friday, April 22, 2016

Fibonacci, LCM and GCD in Haskell


Fibonacci, LCM and GCD in Haskell

by David Lettier

Solving whiteboard problems every now and then can never hurt. We discussed the Fibonacci sequence, LCM and GCD. All solutions were written in Haskell but the algorithms easily translate to other languages. We discussed pattern matching, the Maybe Monad, filter, map andhead. GCD was defined two ways. One way took an iterative approach while the second way, Euclid’s Algorithm, used a simple recursive method.

Thursday, April 14, 2016

Max Subarray in Haskell

Max Subarray in Haskell

By David Lettier

We defined the max or maximum subarray problem as finding the maximum sum of some subarray of contiguous values found in the array. On top this, we added an extra stipulation of finding the maximum sum of non-contiguous elements. Before we could begin, we had to parse and convert the input into arrays of integers. For finding the non-contiguous max sum, we used the foldl or reduce function. For the max subarray problem, we employed a recursive solution keeping track of two inputs where the base case was an empty array.