https://github.com/saadarazzaq/manual-kmeans-clustering-v1
Well Commented K-Means Algorithm WITHOUT any built-in ML Library #1
https://github.com/saadarazzaq/manual-kmeans-clustering-v1
algorithm-implementation kmeans-clustering logic python unsupervised-learning
Last synced: 3 months ago
JSON representation
Well Commented K-Means Algorithm WITHOUT any built-in ML Library #1
- Host: GitHub
- URL: https://github.com/saadarazzaq/manual-kmeans-clustering-v1
- Owner: SaadARazzaq
- Created: 2023-07-17T12:02:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-24T09:13:59.000Z (over 2 years ago)
- Last Synced: 2025-03-17T06:48:04.589Z (8 months ago)
- Topics: algorithm-implementation, kmeans-clustering, logic, python, unsupervised-learning
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Manual Kmeans Clustering #1
This program implements the K-means clustering algorithm without built in functions implementing raw K-Means algorithm of how actually K-Means work in the backend. The program clusters the data into K=2 groups and visualizes the clusters using a scatter plot with different colors for each cluster.
## Dataset
The dataset is read from an Excel file (`Data.csv`) using the pandas library. Make sure the file path is correctly specified in the code.
## Algorithm
The K-means clustering algorithm is implemented using the provided code. The algorithm follows these steps:
1. Initialize the centroids for the clusters.
2. Assign each data point to the nearest centroid based on the Euclidean distance.
3. Calculate the mean of the points in each cluster and update the centroids.
4. Repeat steps 2 and 3 until the centroids no longer change.
## Screenshots

## Dependencies
- Python 3.x
- Pandas
- Matplotlib
Please ensure you have these dependencies installed before running the program.
## Usage
1. Make sure the `Data.csv` file is in the same directory as the script, or specify the correct file path in the code.
2. Run the script using Python.
3. The program will perform K-means clustering on the dataset and display the scatter plot with the clusters.
```bash
python main.py