Bundle Core machine learning types: the seedable Random generator, Matrix2D linear algebra and activations, matrix reference holders, the NeuralNetwork and CSV-backed MatrixReader. Compile with -lib ml.
KMeans
K-Means clustering algorithm
Example
records->AddBack(FloatArrayRef->New([9.677901811, 3.044481052]));
records->AddBack(FloatArrayRef->New([2.103293937, 2.446154204]));
records->AddBack(FloatArrayRef->New([9.340432657, 2.896683906]));
records->AddBack(FloatArrayRef->New([7.674354483, 4.765027229]));
records->AddBack(FloatArrayRef->New([8.656404515, 0.481807722]));
# ...
labels := ["group-a","group-b", "group-c"];
groups := KMeans->Group(labels, records, 2, 0.0, 10.0);
groups->GetGroupNames()->ToString()->PrintLine();
groups->GetDunnIndex()->PrintLine();
each(group in groups) {
group->GetName()->PrintLine();
group->GetArrayValue(0)->PrintLine();
}Operations
Group # native
K-Means group clustering
function : native : Group(group_labels:String[], records:Vector<FloatArrayRef>, record_length:Int, min_value:Float, max_value:Float) ~ KMeansGroupingParameters
| Name | Type | Description |
|---|---|---|
| group_labels | String | group labels used to tag groups also specify K |
| records | Vector<FloatArrayRef> | input records |
| record_length | Int | length of records, all records lengths be the same |
| min_value | Float | smallest record value |
| max_value | Float | largest record value |
Return
| Type | Description |
|---|---|
| KMeansGrouping | labeled grouping |
Group # native
K-Means clustering with k-means++ seeding (deterministic for a given seed), an iteration cap, and explicit empty-cluster handling.
function : native : Group(group_labels:String[], records:Vector<FloatArrayRef>, record_length:Int, min_value:Float, max_value:Float, max_iterations:Int, seed:Int) ~ KMeansGroupingParameters
| Name | Type | Description |
|---|---|---|
| group_labels | String | group labels; the count determines K |
| records | Vector<FloatArrayRef> | input records (all of equal length) |
| record_length | Int | length of each record |
| min_value | Float | smallest record value (kept for API compatibility) |
| max_value | Float | largest record value (kept for API compatibility) |
| max_iterations | Int | hard cap on refinement iterations |
| seed | Int | PRNG seed for reproducible k-means++ initialization |
Return
| Type | Description |
|---|---|
| KMeansGrouping | labeled grouping |