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
- Host: GitHub
- URL: https://github.com/rhettadam/optimal-k
- Owner: rhettadam
- Created: 2024-12-07T04:53:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-08T04:04:29.000Z (over 1 year ago)
- Last Synced: 2025-10-19T05:44:04.853Z (5 months ago)
- Topics: elbow-analysis, elbow-method, elbow-plot, elbow-point, kmeans-analysis, kmeans-clustering, r
- Language: R
- Homepage:
- Size: 11.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)
```
