An simple implementation of Kmeans Unsupervised Learning Algorithm in MATLAB
Explore the project »
Table of Contents
To get a local copy up and running follow these simple example steps.
This project is built using MATLAB. You will need to have it installed on your machine and have Statistics and Machine Learning Toolbox pre-installed in it.
- Get MATLAB running on your machine.
- Clone the repo and resolve dependencies, if any
git clone https://github.com/sayuru-akash/kmeans-clustering-matlab.git
- Place the project in the application folder
- Run the project
This project can be used to understand the Kmeans Clustering Algorithm and how it works. It can also be used to generate figures using MATLAB.
- DATA: To get data for K means clustering, you use MATLAB code “gen_clusterdata”. This code generates your personal data matrix. Use MATLAB command: X=gen_clusterdata(ID), where ID is your student number. The code generates a data matrix X of four columns representing features and N rows representing objects (cases).
- Data analysis.
- Report N - the total number of rows (objects, cases) in your data.
- For each column (feature) from 1 to 4 report: the mean, the standard deviation and the histogram.
- Report the covariance matrix (4x4) and the correlation matrix (4x4).
- Given the number of clusters as 3(i.e.,K=3),implement Kmeans clustering and then repeat the same procedure (i.e., use iteration) to evaluate different number of clusters (i.e., K=3, 4, and 5) to find out the optimal number of classes that achieve the best performance.
- For each K value, report the mean performance using the Silhouette measure and plot the Silhouette for each cluster. (each K value)
- What is the stopping criteria for Kmeans clustering? Plot the clusters and the cluster centroids.
- Report the best K value using the Silhouette measure and the corresponding cluster centroids.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is an academic project done on 2023 and is contributed by
Distributed under the GPL-3.0 License. See LICENSE
for more information.
Sayuru Akash - @sayuru_akash - contact@sayuru.me
Project Link: https://github.com/sayuru-akash/kmeans-clustering-matlab