Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: cluster analysis
Posted:
Jan 15, 2013 12:02 PM
|
|
>> Once you find the cluster centroids you can associate new data example to >> the cluster centers by measuring again the distance (pdist again with one >> entry for each centroid plus un additional entry for each new example). >> Then the analog cluster is the cluster which centroid has the minimal >> distance. ... > I tried to do what you suggested but without success. Can you post a code > example please?
Manuel, if you have centroids and new data, you can locate the nearest centroid to each new point using the pdist2 function like so:
>> centroids = [1 1 1;2 2 2;3 3 3]; >> newdata = 4*rand(4,3) newdata = 2.6274 3.8670 3.4303 0.9275 2.4399 2.4142 2.4878 1.5349 3.3914 0.3005 0.1223 2.0185 >> dists = pdist2(newdata,centroids) dists = 4.0957 2.4341 1.0372 2.0195 1.2309 2.2253 2.8668 1.5460 1.6007 1.5156 2.5327 4.0660 >> [~,minloc] = min(dists,[],2) minloc = 3 2 2 1
However, your original code seemed to me to produce cluster numbers rather than centroids.
-- Tom
|
|
|
|