Algorithm-SVM
view release on metacpan or search on metacpan
lib/Algorithm/SVM.pm view on Meta::CPAN
# Train a new SVM on some new datasets.
$svm->train(@tset);
# Change some of the SVM parameters.
$svm->gamma(64);
$svm->C(8);
# Retrain the SVM with the new parameters.
$svm->retrain();
# Perform cross validation on the training set.
$accuracy = $svm->validate(5);
# Save the model to a file.
$svm->save('new-sample.model');
# Load a saved model from a file.
$svm->load('new-sample.model');
# Retreive the number of classes.
$num = $svm->getNRClass();
lib/Algorithm/SVM.pm view on Meta::CPAN
Loads a model from the specified filename. Returns a false value on failure,
and truth value on success.
$svm->train(@tset);
Trains the SVM on a set of Algorithm::SVM::DataSet objects. @tset should
be an array of Algorithm::SVM::DataSet objects.
$accuracy = $svm->validate(5);
Performs cross validation on the training set. If an argument is provided,
the set is partioned into n subsets, and validated against one another.
Returns a floating point number representing the accuracy of the validation.
$num = $svm->getNRClass();
For a classification model, this function gives the number of classes.
For a regression or a one-class model, 2 is returned.
(@labels) = $svm->getLabels();
For a classification model, this function returns the name of the labels
lib/Algorithm/SVM.pm view on Meta::CPAN
return _train($self->{svm}, 0);
}
sub retrain {
my $self = shift;
return _train($self->{svm}, 1);
}
sub validate {
my ($self, $nfolds) = @_;
$nfolds = 5 if(! defined($nfolds));
croak("NumFolds must be >= 2") if($nfolds < 2);
return _crossValidate($self->{svm}, $nfolds + 0);
}
sub svm_type {
my ($self, $type) = @_;
( run in 0.464 second using v1.01-cache-2.11-cpan-a5abf4f5562 )