emel v0.3.0 Emel.Ml.Perceptron View Source
A binary classification algorithm that makes its predictions based on a linear predictor function combining a set of weights with the feature vector.
Link to this section Summary
Functions
Returns the function that classifies an item by using the Perceptron Algorithm
Link to this section Functions
Link to this function
classifier(dataset, continuous_attributes, boolean_class, learning_rate \\ 0.0001, err_thres \\ 0.1, max_iter \\ 10000)
View Source
Returns the function that classifies an item by using the Perceptron Algorithm.
Examples
iex> f = Emel.Ml.Perceptron.classifier([%{a: 0, b: 0, or: false},
...> %{a: 0, b: 1, or: true},
...> %{a: 1, b: 0, or: true},
...> %{a: 1, b: 1, or: true},
...> ], [:a, :b], :or)
...> f.(%{a: 1, b: 0})
true
iex> f = Emel.Ml.Perceptron.classifier([%{x: 0.0, y: 0.1, x_less_than_y: true},
...> %{x: 0.3, y: 0.2, x_less_than_y: false},
...> %{x: 0.2, y: 0.3, x_less_than_y: true},
...> %{x: 0.3, y: 0.4, x_less_than_y: true},
...> %{x: 0.4, y: 0.3, x_less_than_y: false},
...> %{x: 0.5, y: 0.5, x_less_than_y: false},
...> %{x: 0.5, y: 0.6, x_less_than_y: true},
...> %{x: 0.1, y: 0.2, x_less_than_y: true},
...> %{x: 0.0, y: 0.0, x_less_than_y: false},
...> %{x: 0.1, y: 0.0, x_less_than_y: false},
...> %{x: 0.2, y: 0.1, x_less_than_y: false},
...> %{x: 0.6, y: 0.7, x_less_than_y: true},
...> ], [:x, :y], :x_less_than_y, 0.5, 0.001, 100)
...> f.(%{x: 0.55, y: 0.35})
false