Skip to content

Well Commented K-Means Algorithm WITHOUT any built-in ML Library #1

Notifications You must be signed in to change notification settings

SaadARazzaq/Manual-Kmeans-Clustering-V1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

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

image

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.
python main.py

About

Well Commented K-Means Algorithm WITHOUT any built-in ML Library #1

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages