Open valentinvieriu opened 11 years ago
You don't need this as you can set arbitrary properties on a javascript array. For example:
var colors = [
[20, 20, 80],
[22, 22, 90],
[250, 255, 253],
[0, 30, 70],
[200, 0, 23],
[100, 54, 100],
[255, 13, 8]
];
colors.forEach(function(color, i) {
//Set id for tracking purposes
color.id = i;
});
clusterfck.kmeans(colors, 3);
I think @benjeffery's method would work fine all the way. A more obvious method would be ideal though, something like:
var colors = [
{ id: "blue", value: [0, 0, 255] },
{ id: "orange", value: [200, 50, 50] }
]
where value
always holds the value to be clustered on, but you can store whatever you want in the object otherwise.
This would also allow you to use Float64Array
s for the value (they can't contain arbitrary stuff like reg JS arrays). That could be a big perf win.
Have you made any performance tests using a Float64Array? This could be very interesting.
HI @harthur how do I use your above construct
var colors = [
{ id: "blue", value: [0, 0, 255] },
{ id: "orange", value: [200, 50, 50] }
]
Do I still do
clusterfck.kmeans(colors, 3);
This is not working as expected this way.
The example @harthur gave was how things might work if such a mechanism was implemented. It hasn't been, so you need to something like I suggested above.
For example the first item is an identification item ( userid ) so that I can know who went in wich cluster.
If I run this it just hungs. Is there a way to ignore the first item, and just consider the rest?
Thanks