Module Libsvm.Svm

module Svm: sig .. end


SVM problem and model


module Problem: sig .. end
module Model: sig .. end

SVM training


val train : ?svm_type:[ `C_SVC | `EPSILON_SVR | `NU_SVC | `NU_SVR | `ONE_CLASS ] ->
?kernel:[ `LINEAR | `POLY | `PRECOMPUTED | `RBF | `SIGMOID ] ->
?degree:int ->
?gamma:float ->
?coef0:float ->
?c:float ->
?nu:float ->
?eps:float ->
?cachesize:float ->
?tol:float ->
?shrinking:[ `off | `on ] ->
?probability:bool ->
?weights:(int * float) list ->
?verbose:bool -> Problem.t -> Model.t
train params problem trains a SVM model on the given problem and parameters params:
Raises Failure if parameters are not feasible.
Returns the trained model.
val cross_validation : ?svm_type:[ `C_SVC | `EPSILON_SVR | `NU_SVC | `NU_SVR | `ONE_CLASS ] ->
?kernel:[ `LINEAR | `POLY | `PRECOMPUTED | `RBF | `SIGMOID ] ->
?degree:int ->
?gamma:float ->
?coef0:float ->
?c:float ->
?nu:float ->
?eps:float ->
?cachesize:float ->
?tol:float ->
?shrinking:[ `off | `on ] ->
?probability:bool ->
?weights:(int * float) list ->
?verbose:bool -> n_folds:int -> Problem.t -> Lacaml.D.vec
cross_validation params problem n_folds conducts n-fold cross-validation on the given problem and parameters params. The parameters params are the same as in train above.
Raises Failure if parameters are not feasible.
Returns vector with all predicted values (of all problem instances) in the validation process.

SVM prediction


val predict_one : Model.t -> x:Lacaml.D.vec -> float
predict_one model x does classification or regression on a test vector x given a model. For a classification model, the predicted class for x is returned. For a regression model, the function value of x is returned. For a one-class model, +1 or -1 is returned.
val predict : Model.t -> x:Lacaml.D.mat -> Lacaml.D.vec
predict model x applies predict_one to each row of the matrix x.
val predict_values : Model.t -> x:Lacaml.D.vec -> float array array
predict_values model x
Returns a matrix with decision values on a test vector x.
val predict_probability : Model.t -> x:Lacaml.D.vec -> float * float array
predict_probability m x does classification or regression on a test vector x based on a model with probability information.
Raises Invalid_argument if the model does not support probability estimates.
val predict_from_file : Model.t ->
string -> [ `Expected of Lacaml.D.vec ] * [ `Predicted of Lacaml.D.vec ]
predict_from_file model filename does classification or regression on the testing data given in filename.
Raises Failure if an error occured during parsing of filename.
Returns a pair vectors containing the expected (true) values form the test file and the predicted ones computed from the given model.