SC: FluidLabelSet.cols fails

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

Hello! Nice catch but I don’t think the problem is where you think it is :wink:

We made the method ‘cols’ for a class it make no sense to be called upon, since it will always have a single column (the label for a give ID/entry)

So the error is in the SC class def. Except if I understood everything wrong, which I’m sure @weefuzzy and/or @groma will confirm here.

1 Like

@tremblap is right: I added a method to the SC class that I shouldn’t have, whilst on autopilot. I’ll take it out.

1 Like