![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/292210/image.png)
kmeans of 3d data (clustering)
62 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I need to extend the clustering algorithm (Kmeans) to the third dimension. My dataset is composed: 700 row (different subjects) x 3 columns (each columns = different feature).
Is it possible to obtain the clustering graph in 3d? Is it possible to assign an index (for example 3 ouput, 1 2 3) for each subject based on the 3 characteristics?
For example, I want to assign to subject 1 (which corresponds three specific characteristics) a specific class belonging between one, secondo or third, (3=number of outputs defined a priori)
thanks a million
0 commentaires
Réponses (2)
Ameer Hamza
le 11 Mai 2020
kmeans() supports arbitrary numbers of features, so you can definitely use 3 features. Pass these features as a column of input matrix X. For example
X = rand(1000, 3); % 1000 samples with 3 features
idx = kmeans(X, 3); % 3 number of classes
scatter3(X(:,1), X(:,2), X(:,3), 15, idx, 'filled');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/292210/image.png)
0 commentaires
Tara Rashnavadi
le 16 Nov 2022
this answer which uses plot3 rather than scatter3 worth reading too:
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!