public static class SVM.Trainer<T> extends ClassifierTrainer<T>
Constructor and Description |
---|
Trainer(smile.math.kernel.MercerKernel<T> kernel,
double C)
Constructor of trainer for binary SVMs.
|
Trainer(smile.math.kernel.MercerKernel<T> kernel,
double Cp,
double Cn)
Constructor of trainer for binary SVMs.
|
Trainer(smile.math.kernel.MercerKernel<T> kernel,
double C,
double[] weight,
SVM.Multiclass strategy)
Constructor of trainer for multi-class SVMs.
|
Trainer(smile.math.kernel.MercerKernel<T> kernel,
double C,
int k,
SVM.Multiclass strategy)
Constructor of trainer for multi-class SVMs.
|
Modifier and Type | Method and Description |
---|---|
SVM.Trainer<T> |
setNumEpochs(int epochs)
Sets the number of epochs of stochastic learning.
|
SVM.Trainer<T> |
setTolerance(double tol)
Sets the tolerance of convergence test.
|
SVM<T> |
train(T[] x,
int[] y)
Learns a classifier with given training data.
|
SVM<T> |
train(T[] x,
int[] y,
double[] weight)
Learns a SVM classifier with given training data.
|
setAttributes
public Trainer(smile.math.kernel.MercerKernel<T> kernel, double C)
kernel
- the kernel function.C
- the soft margin penalty parameter.public Trainer(smile.math.kernel.MercerKernel<T> kernel, double Cp, double Cn)
kernel
- the kernel function.Cp
- the soft margin penalty parameter for positive instances.Cn
- the soft margin penalty parameter for negative instances.public Trainer(smile.math.kernel.MercerKernel<T> kernel, double C, int k, SVM.Multiclass strategy)
kernel
- the kernel function.C
- the soft margin penalty parameter.k
- the number of classes.public Trainer(smile.math.kernel.MercerKernel<T> kernel, double C, double[] weight, SVM.Multiclass strategy)
kernel
- the kernel function.C
- the soft margin penalty parameter.weight
- class weight. Must be positive. The soft margin penalty
of class i will be weight[i] * C.public SVM.Trainer<T> setTolerance(double tol)
tol
- the tolerance of convergence test.public SVM.Trainer<T> setNumEpochs(int epochs)
epochs
- the number of epochs of stochastic learning.public SVM<T> train(T[] x, int[] y)
ClassifierTrainer
train
in class ClassifierTrainer<T>
x
- the training instances.y
- the training labels.public SVM<T> train(T[] x, int[] y, double[] weight)
x
- training instances.y
- training labels in [0, k), where k is the number of classes.weight
- instance weight. Must be positive. The soft margin penalty
for instance i will be weight[i] * C.