Greetings,
Thanks for the KMeans clarifications. Working well for me now!
In doing so I noticed that FluidLabelSet’s “.cols” fails and posts: “FAILURE IN SERVER /u_cmd failed”
(fail line is last line in code)
Thanks!
s.boot;
~n_dims = 3;
// make empty dataset
~dataset = FluidDataSet(s,\kmeans_test,~n_dims);
(
100.do({
arg i;
var x,y,z;
var dev = 0.1;
if(i < 30,{
// 30 points clustered around [0,0,0]
x = 0.0;
y = 0.0;
z = 0.0;
},{
if(i < 60,{
// 30 points clustered around [0,0,1]
x = 0.0;
y = 0.0;
z = 1.0;
},{
// 40 points clustered around [1,1,1]
x = 1.0;
y = 1.0;
z = 1.0;
});
});
x = gauss(x,dev);
y = gauss(y,dev);
z = gauss(z,dev);
[x,y,z].postln;
Buffer.loadCollection(s,[x,y,z],1,{
arg buf;
~dataset.addPoint(i.asSymbol,buf);
});
});
)
~kmeans = FluidKMeans.new(s);
(
~kmeans.fit(~dataset,3,1000,action:{
"done".postln
});
)
// need to make a fluid labelset in order to use "get clusters"
~labelset = FluidLabelSet(s,\test_labelset);
~kmeans.predict(~dataset,~labelset, {|x| ("Size of each cluster" + x).postln})
(
~kmeans.getClusters(~dataset,~labelset,{
"done".postln;
});
)
~labelset.cols({arg cols; cols.postln;}); // FAILS