File Exchange

image thumbnail

k-Means (kM) Clustering

version 1.0.0 (2.1 KB) by David Ferreira
Multiple Clusters with the kM and Initialization via k-Means++

6 Downloads

Updated 01 Nov 2020

View License

Function
1. kMeans.predict(Xnew)

Description
1. Returns the estimated clusters of one or multiple test instances.

Example

X = [[1, 2]; [1, 4]; [1, 0];[10, 2]; [10, 4]; [10, 0]];
Xnew = [[0, 0]; [12, 3]];
k = 2;

mdl = kMeans(k);
mdl = mdl.fit(X);
Ypred = mdl.predict(Xnew)

Ypred =

1
2

centroids = mdl.C

1 2
10 2

See examples in the script files.

Cite As

David Ferreira (2021). k-Means (kM) Clustering (https://www.mathworks.com/matlabcentral/fileexchange/82089-k-means-km-clustering), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!