Class LibSVMClassificationTrainer
java.lang.Object
org.tribuo.common.libsvm.LibSVMTrainer<Label>
org.tribuo.classification.libsvm.LibSVMClassificationTrainer
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable,com.oracle.labs.mlrg.olcut.provenance.Provenancable<org.tribuo.provenance.TrainerProvenance>,WeightedLabels,org.tribuo.Trainer<Label>
A trainer for classification models that uses LibSVM.
Note the train method is synchronized on LibSVMTrainer.class due to a global RNG in LibSVM.
This is insufficient to ensure reproducibility if LibSVM is used directly in the same JVM as Tribuo, but
avoids locking on classes Tribuo does not control.
See:
Chang CC, Lin CJ. "LIBSVM: a library for Support Vector Machines" ACM transactions on intelligent systems and technology (TIST), 2011.for the nu-svc algorithm:
Schölkopf B, Smola A, Williamson R, Bartlett P L. "New support vector algorithms" Neural Computation, 2000, 1207-1245.and for the original algorithm:
Cortes C, Vapnik V. "Support-Vector Networks" Machine Learning, 1995.
-
Field Summary
Fields inherited from class org.tribuo.common.libsvm.LibSVMTrainer
parameters, svmTypeFields inherited from interface org.tribuo.Trainer
DEFAULT_SEED, INCREMENT_INVOCATION_COUNT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFor OLCUT.LibSVMClassificationTrainer(SVMParameters<Label> parameters) Constructs a classification LibSVM trainer using the specified parameters andTrainer.DEFAULT_SEED.LibSVMClassificationTrainer(SVMParameters<Label> parameters, long seed) Constructs a classification LibSVM trainer using the specified parameters and seed. -
Method Summary
Modifier and TypeMethodDescriptionprotected LibSVMModel<Label> createModel(org.tribuo.provenance.ModelProvenance provenance, org.tribuo.ImmutableFeatureMap featureIDMap, org.tribuo.ImmutableOutputInfo<Label> outputIDInfo, List<libsvm.svm_model> models) protected com.oracle.labs.mlrg.olcut.util.Pair<libsvm.svm_node[][], double[][]> extractData(org.tribuo.Dataset<Label> data, org.tribuo.ImmutableOutputInfo<Label> outputInfo, org.tribuo.ImmutableFeatureMap featureMap) voidUsed by the OLCUT configuration system, and should not be called by external code.voidsetLabelWeights(Map<Label, Float> weights) protected libsvm.svm_parametersetupParameters(org.tribuo.ImmutableOutputInfo<Label> outputIDInfo) protected List<libsvm.svm_model> trainModels(libsvm.svm_parameter curParams, int numFeatures, libsvm.svm_node[][] features, double[][] outputs, SplittableRandom localRNG) Methods inherited from class org.tribuo.common.libsvm.LibSVMTrainer
exampleToNodes, getInvocationCount, getProvenance, setInvocationCount, toString, train, train, train
-
Constructor Details
-
LibSVMClassificationTrainer
protected LibSVMClassificationTrainer()For OLCUT. -
LibSVMClassificationTrainer
Constructs a classification LibSVM trainer using the specified parameters andTrainer.DEFAULT_SEED.- Parameters:
parameters- The SVM parameters.
-
LibSVMClassificationTrainer
Constructs a classification LibSVM trainer using the specified parameters and seed.- Parameters:
parameters- The SVM parameters.seed- The RNG seed for LibSVM's internal RNG.
-
-
Method Details
-
postConfig
Used by the OLCUT configuration system, and should not be called by external code.- Specified by:
postConfigin interfacecom.oracle.labs.mlrg.olcut.config.Configurable- Overrides:
postConfigin classLibSVMTrainer<Label>
-
createModel
protected LibSVMModel<Label> createModel(org.tribuo.provenance.ModelProvenance provenance, org.tribuo.ImmutableFeatureMap featureIDMap, org.tribuo.ImmutableOutputInfo<Label> outputIDInfo, List<libsvm.svm_model> models) - Specified by:
createModelin classLibSVMTrainer<Label>
-
trainModels
protected List<libsvm.svm_model> trainModels(libsvm.svm_parameter curParams, int numFeatures, libsvm.svm_node[][] features, double[][] outputs, SplittableRandom localRNG) - Specified by:
trainModelsin classLibSVMTrainer<Label>
-
extractData
protected com.oracle.labs.mlrg.olcut.util.Pair<libsvm.svm_node[][], double[][]> extractData(org.tribuo.Dataset<Label> data, org.tribuo.ImmutableOutputInfo<Label> outputInfo, org.tribuo.ImmutableFeatureMap featureMap) - Specified by:
extractDatain classLibSVMTrainer<Label>
-
setupParameters
- Overrides:
setupParametersin classLibSVMTrainer<Label>
-
setLabelWeights
- Specified by:
setLabelWeightsin interfaceWeightedLabels
-