Penelope v0.2.1 Penelope.ML.SVM.Classifier
The SVM classifier uses libsvm for multi-class classification. It provides support for training a model, compiling/extracting model parameters to/from erlang data structures, and predicting classes or probabilities.
Features are represented as lists of dense Vector instances. Classes can be any value, and class labels for training are lists of these.
Model parameters are elixir analogs of those supported by libsvm. See https://github.com/cjlin1/libsvm for details.
Link to this section Summary
Functions
compiles a pre-trained model
extracts model parameters from the compiled model
trains an SVM model and returns it as a compiled model
predicts a list of target classes from a list of feature vectors
predicts probabilities for all classes from a feature vector
Link to this section Functions
compiles a pre-trained model
extracts model parameters from the compiled model
These parameters are simple elixir objects and can later be passed to
compile
to prepare the model for inference.
fit(context :: map(), x :: [Penelope.ML.Vector.t()], y :: [any()], options :: keyword()) :: map()
trains an SVM model and returns it as a compiled model
key | description | default |
---|---|---|
kernel | one of :linear /:rbf /:poly /:sigmoid | :linear |
degree | polynomial degree | 3 |
gamma | training example reach - :auto for 1/N | :auto |
coef0 | independent term | 0.0 |
c | error term penalty | 1.0 |
weights | class weights map - :auto for balanced | :auto |
epsilon | tolerance for stopping | 0.001 |
cache_size | kernel cache size, in MB | 1 |
shrinking? | use the shrinking heuristic? | true |
probability? | enable class probabilities? | false |
predict_class(%{svm: reference(), classes: [any()]}, context :: map(), [x :: Penelope.ML.Vector.t()]) :: [any()]
predicts a list of target classes from a list of feature vectors
predict_probability(%{svm: reference(), classes: [any()]}, context :: map(), [x :: Penelope.ML.Vector.t()]) :: [%{optional(any()) => float()}]
predicts probabilities for all classes from a feature vector
The results are returned in a map of %{label => probability}
.