package libsvm
Module Libsvm.SvmSource
SVM problem and model
SVM training
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.ttrain params problem trains a SVM model on the given problem and parameters params:
svm_type- type of SVM classification/regression (defaultC_SVC)kernel- type of the SVM kernel (defaultRBF)degree- the exponent in thePOLYkernel (default 3)gamma- parameter forPOLY,RBFandSIGMOIDkernel (default 0)coef0- parameter forPOLYandSIGMOIDkernel (default 0)c- the cost of constraints violation inC_SVC,EPSILON_SVR, andNU_SVR(default 1)nu- the parameter inNU_SVM,NU_SVRandONE_CLASS(default 0.5)eps- the epsilon in the epsilon-sensitive loss function ofEPSILON_SVR(default 0.1)cachesize- the size of the kernel cache in megabytes (default 100)tol- the stopping criterion (default 1e-3)shrinking- useonto conduct shrinking, otherwiseoff(defaulton)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.veccross_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.
SVM prediction
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.
predict_values_sparse model x
predict_probability m x does classification or regression on a test vector x based on a model with probability information.
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.
predict model x applies predict_one to each row of the matrix x.
predict_values model x
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.