emel v0.3.0 Emel.Ml.KMeans View Source
Aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean.
Link to this section Summary
Functions
Returns the function that classifies an item by identifying the cluster it belongs to
points
partitioned into k
clusters in which each point belongs to the cluster with the nearest mean
Link to this section Functions
Returns the function that classifies an item by identifying the cluster it belongs to.
Examples
iex> f = Emel.Ml.KMeans.classifier([%{x1: 1.0, x2: 1.0},
...> %{x1: 2.0, x2: 1.0},
...> %{x1: 4.0, x2: 3.0},
...> %{x1: 5.0, x2: 4.0}],
...> [:x1, :x2],
...> ["0", "1"])
...> f.(%{x1: 1.5, x2: 1.5})
"0"
points
partitioned into k
clusters in which each point belongs to the cluster with the nearest mean.
Examples
iex> Emel.Ml.KMeans.clusters([[1.0, 1.0],
...> [2.0, 1.0],
...> [4.0, 3.0],
...> [5.0, 4.0]],
...> 2)
[[[1.0, 1.0], [2.0, 1.0]],
[[4.0, 3.0], [5.0, 4.0]]]
iex> Emel.Ml.KMeans.clusters([[0.0, 0.0],
...> [4.0, 4.0],
...> [9.0, 9.0],
...> [4.3, 4.3],
...> [9.9, 9.9],
...> [4.4, 4.4],
...> [0.1, 0.1]],
...> 3)
[
[
[0.0, 0.0],
[4.0, 4.0],
[4.3, 4.3],
[4.4, 4.4],
[0.1, 0.1]
],
[[9.0, 9.0]],
[[9.9, 9.9]]
]