MATLAB kmeans clustering vector space
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Tom Lane
2013년 3월 14일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!