Shweta, the answer is here:
KMEANS K-means clustering.
...
[ ... ] = KMEANS(..., 'PARAM1',val1, 'PARAM2',val2, ...) allows you to
...
'Start' - Method used to choose initial cluster centroid positions,
sometimes known as "seeds". Choices are:
{'sample'} - Select K observations from X at random
The algorithm needs a starting value, which in this case is a set of K
univariate cluster means. I suspect if you fix the starting values, your
results won't vary.
There's another option:
'Replicates' - Number of times to repeat the clustering, each with a
new set of initial centroids [ positive integer | {1}]
This takes advantage of the random starting points by running the procedure
multiple times, and taking as a final answer the results that minimize the
within-cluster distances.
-- Tom
> The algorithm needs a starting value, which in this case is a set of K
> univariate cluster means. I suspect if you fix the starting values, your
> results won't vary.
It may also be that the different results on different runs are simply
permutations of the cluster numbers.
Shweta <shwetaan...@gmail.com> wrote in message
<ef511...@webcrossing.raydaftYaTP>...
The answer is here:
>> help kmeans
KMEANS K-means clustering.
IDX = KMEANS(X, K) partitions the points in the N-by-P data matrix
...
'Start' - Method used to choose initial cluster centroid positions,
sometimes known as "seeds". Choices are:
...
matrix - A K-by-P matrix of starting locations. In this case,
you can pass in [] for K, and KMEANS infers K from
the first dimension of the matrix. You can also
supply a 3D array, implying a value for 'Replicates'
from the array's third dimension.
-- Tom
Here I use kmeans on the Fisher iris data, starting with the three species
means. I plot the results and compare the clusters to the known species.
-- Tom
>> load fisheriris
>> m = grpstats(meas,species)
m =
5.0060 3.4280 1.4620 0.2460
5.9360 2.7700 4.2600 1.3260
6.5880 2.9740 5.5520 2.0260
>> g = kmeans(meas,3,'start',m);
>> gplotmatrix(meas,[],g)
>> crosstab(g,species)
ans =
50 0 0
0 48 14
0 2 36
I executed his example and I obtained the same answer that I have been obtaining in my application, or be:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> prwaitbar at 159
N(DEPTH) = n; % complete the admin
Error in ==> kmeans at 57
prwaitbar(maxit,'k-means clustering');
I already verified the code of the prwaitbar and I didn't get to solve the problem. Would know how to tell me how it could avoid this mistake?
Thank you very much!!
Are you sure you are using the kmeans provided in the stats toolbox? Type
which kmeans
In my installations 2009a or 2010a the stats toolbox versions of kmeans don't have use anything called prwaitbar.
I typed,
>> which kmeans
C:\Matlab\toolbox\stats\kmeans.m
my version is 7.0.0.19920 (R14), what could be?
There is a non-MathWorks thing called prtools. I don't know what it is, but
it has a kmeans function, a crossval function, and a prwaitbar function. It
appears you were calling the prtools function originally. But then later,
when you issued the "which" command, you didn't see that. I can't explain
the difference.
If you give the command
which kmeans -all
you may see both the Statistics Toolbox version and the prtools version. If
so, try temporarily removing prtools from your path. (Or just cd out of that
directory if that's where you are.) If you just see the statistics one
again, try repeating the example to see if it works this time.
-- Tom
thanks
yafit
If you type "help kmeans" you will see:
[IDX, C, SUMD] = KMEANS(X, K)
You have named your second output variable sumd, so I suspect you really
want the third output. Here's one way to do that:
[g, ~, sumd] = kmeans(...)
-- Tom
i though that was the problem , only didnt know how to solve it, your soulution seems simple i wish it worked, for some reason it doest , i keep getting error:
(x has data, m has 3 centers if i run it without the sign it work perfectly-can you see anything wrong???
>> [idx,~,sumd] = kmeans(x,3,'start',m);
??? [idx,~,sumd] = kmeans(x,3,'start',m);
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
thank you!
"yafit maymon" <yafi...@gmail.com> wrote in message
news:ia4fn2$30t$1...@fred.mathworks.com...
If you're using a version of MATLAB prior to release R2009b, this syntax
will not work for you.
http://www.mathworks.com/help/techdoc/rn/br5fo8o-1.html#br65zmd-1
Replace the tilde in the output argument with a dummy variable name.
--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
hi steve,
so my 2008 version is the problem ..
i tried your solution and it works perfectly
thak you !
yafit