Penelope v0.1.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 are represented as integers, 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 and adds it to the pipeline context
extracts model parameters from the pipeline context map
trains an SVM model and adds it to the pipeline context map
predicts a target class from a feature vector
predicts probabilities for all classes from a feature vector
Link to this section Functions
compiles a pre-trained model and adds it to the pipeline context
extracts model parameters from the pipeline context map
These parameters are simple elixir objects and can later be passed to
compile
to add the model back to the context.
fit(context :: map(), x :: [Penelope.ML.Vector.t()], y :: [integer()], options :: keyword()) :: {map(), [Penelope.ML.Vector.t()], [integer()]}
trains an SVM model and adds it to the pipeline context map
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 | a |
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_model: reference()}, x :: Penelope.ML.Vector.t()) :: integer()
predicts a target class from a feature vector
predict_probability(%{svm_model: reference()}, x :: Penelope.ML.Vector.t()) :: %{optional(integer()) => float()}
predicts probabilities for all classes from a feature vector
The results are returned in a map of %{label => probability}
.