An open API service indexing awesome lists of open source software.

https://github.com/rhettadam/optimal-k

Function to find the optimal number of clusters for k-means analysis using the Elbow Method
https://github.com/rhettadam/optimal-k

elbow-analysis elbow-method elbow-plot elbow-point kmeans-analysis kmeans-clustering r

Last synced: 25 days ago
JSON representation

Function to find the optimal number of clusters for k-means analysis using the Elbow Method

Awesome Lists containing this project

README

          

# Optimal-K

## Overview
`Optimal-K` is an R function to determine the optimal number of clusters in [K-Means clustering](https://www.geeksforgeeks.org/k-means-clustering-introduction/) using the [Elbow Method](https://www.geeksforgeeks.org/elbow-method-for-optimal-value-of-k-in-kmeans/). This function helps users decide the best value of `k` by identifying the elbow point on the WCSS (Within-Cluster Sum of Squares) curve.

## How It Works
The function works by calculating the perpendicular distance of each point on the WCSS curve to the line connecting the first and last points of the curve. The point with the maximum distance is identified as the "elbow," and its corresponding `k` value is returned.

### Function Definition:
```R
find_optimal_k(wcss_values, k_values)
```

![Screenshot 2024-12-06 231351](https://github.com/user-attachments/assets/8f8d667e-33d9-4079-ae00-a3d5d0bd241c)