Turn data into functions! A simple and functional machine learning library, (re)implemented in Gleam for the Erlang ecosystem.
- For Erlang projects, add the dependency into
rebar.config
:
{deps, [
{emel, "1.0.0"}
]}.
- For Elixir projects, add the dependency into
mix.exs
:
defp deps do
[
{:emel, "~> 1.0.0"}
]
end
- For Gleam projects, run
gleam add emel
.
Data = [
{[7.0, 7.0], "bad"},
{[7.0, 4.0], "bad"},
{[3.0, 4.0], "good"},
{[1.0, 4.0], "good"}
],
F = emel@ml@k_nearest_neighbors:classifier(Data, 3),
F([3.0, 7.0]). % "good"
data = [
{[1.794638, 15.15426], 0.510998918},
{[3.220726, 229.6516], 105.6583692},
{[5.780040, 3480.201], 1776.99}
]
f = :emel@ml@linear_regression.predictor(data)
f.([3.0, 230.0]) # 106.74114058686602
import emel/ml/neural_network as nn
let data = [
#([0.8, 0.0, 0.0], "x"),
#([0.0, 0.9, 0.0], "y"),
#([0.0, 0.0, 0.8], "z"),
]
let f = nn.classifier(
data,
[4], // hidden layers
0.01, // learning rate
0.1, // error threshold
1000 // maximum iterations
)
f([0.0, 0.8, 0.0]) // "y"
The documentation describes all the public functions. Gleam developers can pay attention to the type annotations. Erlang and Elixir devs may take a look at the examples which are written in Erlang.
- Linear Regression
- K Nearest Neighbors
- Decision Tree
- Naive Bayes
- K Means
- Perceptron
- Logistic Regression
- Neural Network
For the documentation of the previous version (0.3.0
), click here.