Skip to content

Instantly share code, notes, and snippets.

View dancansikuku94's full-sized avatar

Dancan Sikuku dancansikuku94

View GitHub Profile
@MickaelBergem
MickaelBergem / install-vuejs-doc.sh
Created April 20, 2019 03:13
Download and build the Vue.JS documentation for offline access
# Clone the repository
git clone https://github.com/vuejs/vuejs.org.git
cd vuejs.org
# Install the JS dependencies
yarn
# Start the server
yarn start
# The server should now be running on http://localhost:4000/
@rpgove
rpgove / README.md
Last active April 30, 2025 15:43
Using the elbow method to determine the optimal number of clusters for k-means clustering

K-means is a simple unsupervised machine learning algorithm that groups a dataset into a user-specified number (k) of clusters. The algorithm is somewhat naive--it clusters the data into k clusters, even if k is not the right number of clusters to use. Therefore, when using k-means clustering, users need some way to determine whether they are using the right number of clusters.

One method to validate the number of clusters is the elbow method. The idea of the elbow method is to run k-means clustering on the dataset for a range of values of k (say, k from 1 to 10 in the examples above), and for each value of k calculate the sum of squared errors (SSE). Like this:

var sse = {};
for (var k = 1; k <= maxK; ++k) {
    sse[k] = 0;
    clusters = kmeans(dataset, k);
    clusters.forEach(function(cluster) {

mean = clusterMean(cluster);