MATLAB kmeans clustering vector space
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a slight problem. I am stuck on trying to apply a clustering algorithm on the term-frequency vectors corresponding to documents which I earlier retrieved from another script.
I want a script that uses Matlab's kmeans function and normalizes each document vector and produces output if possible.
This is what I have done so far. Could you please assist me wherever possible:
%function name clustering to take parameters term frequeuncy vectors and
%cluster N number
%tdfm is the document we want to apply clustering to.
function [X,Y] = clustering(tdfm,N)
%normalise first parameter to remove bias of length of each document
for j=1:length(tdfm)
normalisedVect = norm(tdfm{j});
end
%insert kmeans function to compute cluster with second parameter.
[X,Y]=kmeans(normalisedVect,N);
The normalisedVect will need to be a cell array to store the normalised vectors which will then have the kmeans function applied to it.
The dimensions of the tdfm are 8033X750 so 2 dimensional.
One last question, do anyone know how I could display output of the kmeans function additionally-possibly graphically?
0 commentaires
Réponses (1)
Tom Lane
le 14 Mar 2013
A couple of things to look at. First, norm(m) where m is a matrix returns a scalar. You seem to want a vector. Second, in your loop you repeatedly assign to the variable normalizedVect, so at the end of the loop only the final scalar value is left.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!