Library
Module
Module type
Parameter
Class
Class type
val load_dataset : string -> (int * float) list array * Lacaml.D.vec
module Problem : sig ... end
module Model : sig ... end
val train :
?svm_type:[ `C_SVC | `NU_SVC | `ONE_CLASS | `EPSILON_SVR | `NU_SVR ] ->
?kernel:[ `LINEAR | `POLY | `RBF | `SIGMOID | `PRECOMPUTED ] ->
?degree:int ->
?gamma:float ->
?coef0:float ->
?c:float ->
?nu:float ->
?eps:float ->
?cachesize:float ->
?tol:float ->
?shrinking:[ `on | `off ] ->
?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
:
svm_type
- type of SVM classification/regression (default C_SVC
)kernel
- type of the SVM kernel (default RBF
)degree
- the exponent in the POLY
kernel (default 3)gamma
- parameter for POLY
, RBF
and SIGMOID
kernel (default 0)coef0
- parameter for POLY
and SIGMOID
kernel (default 0)c
- the cost of constraints violation in C_SVC
, EPSILON_SVR
, and NU_SVR
(default 1)nu
- the parameter in NU_SVM
, NU_SVR
and ONE_CLASS
(default 0.5)eps
- the epsilon in the epsilon-sensitive loss function of EPSILON_SVR
(default 0.1)cachesize
- the size of the kernel cache in megabytes (default 100)tol
- the stopping criterion (default 1e-3)shrinking
- use on
to conduct shrinking, otherwise off
(default on
)probability
- if probability = true, then a model with probability information will be obtained (default false)weights
- weights to penalize classes (default = )verbose
- if verbose = true, then train the SVM in verbose mode (default false)val cross_validation :
?svm_type:[ `C_SVC | `NU_SVC | `ONE_CLASS | `EPSILON_SVR | `NU_SVR ] ->
?kernel:[ `LINEAR | `POLY | `RBF | `SIGMOID | `PRECOMPUTED ] ->
?degree:int ->
?gamma:float ->
?coef0:float ->
?c:float ->
?nu:float ->
?eps:float ->
?cachesize:float ->
?tol:float ->
?shrinking:[ `on | `off ] ->
?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.
val predict_sparse : Model.t -> (int * float) list -> float
predict_sparse 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_values_sparse : Model.t -> (int * float) list -> float array array
predict_values_sparse model x
val predict_probability_sparse :
Model.t ->
(int * float) list ->
float * float array
predict_probability m x
does classification or regression on a test vector x
based on a model
with probability information.
val predict_one : Model.t -> 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 -> Lacaml.D.mat -> Lacaml.D.vec
predict model x
applies predict_one to each row of the matrix x
.
val predict_values : Model.t -> Lacaml.D.vec -> float array array
predict_values model x
val predict_probability : Model.t -> 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.
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
.