SVM
class SVM (View source)
Support Vector Machine Library
LibSVM is an efficient solver for SVM classification and regression problems. The svm extension wraps this in a PHP interface for easy use in PHP scripts.
Constants
C_SVC |
The basic C_SVC SVM type. The default, and a good starting point |
NU_SVC |
NU_SVC type uses a different, more flexible, error weighting |
ONE_CLASS |
One class SVM type. Train just on a single class, using outliers as negative examples |
EPSILON_SVR |
A SVM type for regression (predicting a value rather than just a class) |
NU_SVR |
A NU style SVM regression type |
KERNEL_LINEAR |
A very simple kernel, can work well on large document classification problems |
KERNEL_POLY |
A polynomial kernel |
KERNEL_RBF |
The common Gaussian RBD kernel. Handles non-linear problems well and is a good default for classification |
KERNEL_SIGMOID |
A kernel based on the sigmoid function. Using this makes the SVM very similar to a two layer sigmoid based neural network |
KERNEL_PRECOMPUTED |
A precomputed kernel - currently unsupported. |
OPT_TYPE |
The options key for the SVM type |
OPT_KERNEL_TYPE |
The options key for the kernel type |
OPT_DEGREE |
|
OPT_SHRINKING |
Training parameter, boolean, for whether to use the shrinking heuristics |
OPT_PROPABILITY |
Training parameter, boolean, for whether to collect and use probability estimates |
OPT_GAMMA |
Algorithm parameter for Poly, RBF and Sigmoid kernel types. |
OPT_NU |
The option key for the nu parameter, only used in the NU_ SVM types |
OPT_EPS |
The option key for the Epsilon parameter, used in epsilon regression |
OPT_P |
Training parameter used by Episilon SVR regression |
OPT_COEF_ZERO |
Algorithm parameter for poly and sigmoid kernels |
OPT_C |
The option for the cost parameter that controls tradeoff between errors and generality - effectively the penalty for misclassifying training examples. |
OPT_CACHE_SIZE |
Memory cache size, in MB |
Methods
Construct a new SVM object
Test training params on subsets of the training data
Return the current training parameters
Set training parameters
Details
__construct()
Construct a new SVM object
Constructs a new SVM object ready to accept training data.
float
crossvalidate(array $problem, int $number_of_folds)
Test training params on subsets of the training data
Crossvalidate can be used to test the effectiveness of the current parameter set on a subset of the training data. Given a problem set and a n "folds", it separates the problem set into n subsets, and the repeatedly trains on one subset and tests on another. While the accuracy will generally be lower than a SVM trained on the enter data set, the accuracy score returned should be relatively useful, so it can be used to test different training parameters.
array
getOptions()
Return the current training parameters
Retrieve an array containing the training parameters. The parameters will be keyed on the predefined SVM constants.
bool
setOptions(array $params)
Set training parameters
Set one or more training parameters.
SVMModel
train(array $problem, array $weights = null)
Create a SVMModel based on training data
Train a support vector machine based on the supplied training data.