k_means_(d, k, distance)
I have developed a k-means algorithm which accepts a maximum of 5 clusters. You can specify distance measure to use, i.e. 'euclidean', 'cosine' etc. and the function will also produce a scatter plot of your clustered data.
Please note:
- This is my first attempt at creating a k-means algorithm (created for university module work)
- It is by no means the fastest k-means algorithm available
- Uses random initialisation for initial centroids
- k_means_(d,k,distance)
- I have only tested it with a few types of data and have had great success, hopefully you won't have any problems
- If you are unfamiliar with this algorithm, please note that it requires a minimum of 2 dimensions for it to work.
- Use only numerical data i.e. ratio, interval. This algorithm is not suitable for categorical or ordinal data types.
Cite As
dangrewal (2024). k_means_(d, k, distance) (https://www.mathworks.com/matlabcentral/fileexchange/48476-k_means_-d-k-distance), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- AI, Data Science, and Statistics > Statistics and Machine Learning Toolbox >
- MATLAB > Graphics > 2-D and 3-D Plots > Discrete Data Plots >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.