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

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

compiles a pre-trained model

Link to this function export(map)
export(%{svm: reference(), classes: [any()]}) :: map()

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.

Link to this function fit(context, x, y, options \\ [])
fit(context :: map(), x :: [Penelope.ML.Vector.t()], y :: [any()], options :: keyword()) :: map()

trains an SVM model and returns it as a compiled model

keydescriptiondefault
kernelone of :linear/:rbf/:poly/:sigmoid:linear
degreepolynomial degree3
gammatraining example reach - :auto for 1/N:auto
coef0independent term0.0
cerror term penalty1.0
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 predict_class(model, context, x)
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

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