Penelope v0.1.0 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

trains an SVM model and adds it to the pipeline context map

extracts model parameters from 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

Link to this function compile(context, params)
compile(context :: map, params :: map) :: map

compiles a pre-trained model and adds it to the pipeline context

Link to this function fit(context, x, y, options \\ [])
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

keydescriptiondefault
kernelone of :linear/:rbf/:poly/:sigmoid:linear
degreepolynomial degree3
gammatraining example reach - :auto for 1/N:auto
coef0independent term0.0
cerror term penaltya
weightsclass weights map - :auto for balanced:auto
epsilontolerance for stopping0.001
cache_sizekernel cache size, in MB1
shrinking?use the shrinking heuristic?true
probability?enable class probabilities?false
Link to this function inspect(map)
inspect(%{svm_model: reference}) :: map

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.

Link to this function predict_class(map, x)
predict_class(%{svm_model: reference}, x :: Penelope.ML.Vector.t) :: integer

predicts a target class from a feature vector

Link to this function predict_probability(map, x)
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}.