-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
I would expect using setMeans with a dataset of n clusters would automatically set the KMeans object to look for n means, but it seems it does not. Instead I get ERROR: FluidKMeans - Wrong number of initial points. Is this intended behaviour?
s.boot;
// make and plot a dataset with 5 globs
(
fork{
var counter = 0;
var dict = Dictionary.newFrom(["cols",2,"data",Dictionary.new]);
var xybuf = Buffer.alloc(s,2);
1000.do{
arg i;
var x = [0.3,0.7,0.5,0.7,0.3][i % 5];
var y = [0.3,0.7,0.5,0.3,0.7][i % 5];
x = gauss(x,0.03).clip(0,1);
y = gauss(y,0.03).clip(0,1);
dict["data"][i] = [x,y];
};
~mean_seeds = FluidDataSet(s);
~fp = FluidPlotter(bounds:Rect(0,0,800,800),dict:dict,mouseMoveAction:{
arg view, x, y;
xybuf.setn(0,[x,y]);
~mean_seeds.addPoint(counter,xybuf,{
counter = counter + 1;
~mean_seeds.print;
});
});
}
)
(
~ds = FluidDataSet(s).load(~fp.dict);
~kmeans = FluidKMeans(s).setMeans(~mean_seeds);
~labels = FluidLabelSet(s);
~kmeans.fitPredict(~ds,~labels,{
~labels.dump({
arg labels;
~fp.categories_(labels);
});
});
)