SVMModel
class SVMModel (View source)
The SVMModel is the end result of the training process. It can be used to classify previously unseen data.
Methods
Returns true if the model has probability information
Construct a new SVMModel
Get the labels the model was trained on
Returns the number of classes the model was trained with
Get the SVM type the model was trained with
Get the sigma value for regression types
Load a saved SVM Model
Return class probabilities for previous unseen data
Predict a value for previously unseen data
Save a model to a file, for later use
Details
bool
checkProbabilityModel()
Returns true if the model has probability information
__construct(string $filename = '')
Construct a new SVMModel
Build a new SVMModel. Models will usually be created from the SVM::train function, but then saved models may be restored directly.
array
getLabels()
Get the labels the model was trained on
Return an array of labels that the model was trained on. For regression and one class models an empty array is returned.
int
getNrClass()
Returns the number of classes the model was trained with
Returns the number of classes the model was trained with, will return 2 for one class and regression models.
int
getSvmType()
Get the SVM type the model was trained with
Returns an integer value representing the type of the SVM model used, e.g SVM::C_SVC.
float
getSvrProbability()
Get the sigma value for regression types
For regression models, returns a sigma value. If there is no probability information or the model is not SVR, 0 is returned.
bool
load(string $filename)
Load a saved SVM Model
float
predict_probability(array $data)
Return class probabilities for previous unseen data
This function accepts an array of data and attempts to predict the class, as with the predict function. Additionally, however, this function returns an array of probabilities, one per class in the model, which represent the estimated chance of the data supplied being a member of that class. Requires that the model to be used has been trained with the probability parameter set to true.
float
predict(array $data)
Predict a value for previously unseen data
This function accepts an array of data and attempts to predict the class or regression value based on the model extracted from previously trained data.
bool
save(string $filename)
Save a model to a file, for later use