Class LibSVMAnomalyTrainer
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable
,com.oracle.labs.mlrg.olcut.provenance.Provenancable<TrainerProvenance>
,Trainer<Event>
A trainer for anomaly models that uses LibSVM.
See:
Chang CC, Lin CJ. "LIBSVM: a library for Support Vector Machines" ACM transactions on intelligent systems and technology (TIST), 2011.
and for the anomaly detection algorithm:
Schölkopf B, Platt J, Shawe-Taylor J, Smola A J, Williamson R C. "Estimating the support of a high-dimensional distribution" Neural Computation, 2001, 1443-1471.
-
Field Summary
Fields inherited from class org.tribuo.common.libsvm.LibSVMTrainer
parameters, svmType
Fields inherited from interface org.tribuo.Trainer
DEFAULT_SEED
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
For OLCUT.LibSVMAnomalyTrainer
(SVMParameters<Event> parameters) Creates a one-class LibSVM trainer using the supplied parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected LibSVMModel
<Event> createModel
(ModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<Event> outputIDInfo, List<libsvm.svm_model> models) Construct the appropriate subtype of LibSVMModel for the prediction task.protected com.oracle.labs.mlrg.olcut.util.Pair
<libsvm.svm_node[][], double[][]> extractData
(Dataset<Event> data, ImmutableOutputInfo<Event> outputInfo, ImmutableFeatureMap featureMap) Extracts the features andOutput
s in LibLinear's format.protected double
extractOutput
(Event output) Converts an output into a double for use in training.void
Used by the OLCUT configuration system, and should not be called by external code.train
(Dataset<Event> dataset, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> instanceProvenance) Trains a predictive model using the examples in the given data set.protected List
<libsvm.svm_model> trainModels
(libsvm.svm_parameter curParams, int numFeatures, libsvm.svm_node[][] features, double[][] outputs) Train all the liblinear instances necessary for this dataset.Methods inherited from class org.tribuo.common.libsvm.LibSVMTrainer
exampleToNodes, getInvocationCount, getProvenance, setupParameters, toString, train
-
Constructor Details
-
LibSVMAnomalyTrainer
protected LibSVMAnomalyTrainer()For OLCUT. -
LibSVMAnomalyTrainer
Creates a one-class LibSVM trainer using the supplied parameters.- Parameters:
parameters
- The training parameters.
-
-
Method Details
-
postConfig
Used by the OLCUT configuration system, and should not be called by external code.- Specified by:
postConfig
in interfacecom.oracle.labs.mlrg.olcut.config.Configurable
- Overrides:
postConfig
in classLibSVMTrainer<Event>
-
train
public LibSVMModel<Event> train(Dataset<Event> dataset, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> instanceProvenance) Description copied from interface:Trainer
Trains a predictive model using the examples in the given data set.- Specified by:
train
in interfaceTrainer<Event>
- Overrides:
train
in classLibSVMTrainer<Event>
- Parameters:
dataset
- the data set containing the examples.instanceProvenance
- Training run specific provenance (e.g., fold number).- Returns:
- a predictive model that can be used to generate predictions for new examples.
-
createModel
protected LibSVMModel<Event> createModel(ModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<Event> outputIDInfo, List<libsvm.svm_model> models) Description copied from class:LibSVMTrainer
Construct the appropriate subtype of LibSVMModel for the prediction task.- Specified by:
createModel
in classLibSVMTrainer<Event>
- Parameters:
provenance
- The model provenance.featureIDMap
- The feature id map.outputIDInfo
- The output id info.models
- The svm models.- Returns:
- An implementation of LibSVMModel.
-
trainModels
protected List<libsvm.svm_model> trainModels(libsvm.svm_parameter curParams, int numFeatures, libsvm.svm_node[][] features, double[][] outputs) Description copied from class:LibSVMTrainer
Train all the liblinear instances necessary for this dataset.- Specified by:
trainModels
in classLibSVMTrainer<Event>
- Parameters:
curParams
- The LibLinear parameters.numFeatures
- The number of features in this dataset.features
- The features themselves.outputs
- The outputs.- Returns:
- A list of liblinear models.
-
extractData
protected com.oracle.labs.mlrg.olcut.util.Pair<libsvm.svm_node[][], double[][]> extractData(Dataset<Event> data, ImmutableOutputInfo<Event> outputInfo, ImmutableFeatureMap featureMap) Description copied from class:LibSVMTrainer
Extracts the features andOutput
s in LibLinear's format.- Specified by:
extractData
in classLibSVMTrainer<Event>
- Parameters:
data
- The input data.outputInfo
- The output info.featureMap
- The feature info.- Returns:
- The features and outputs.
-
extractOutput
Converts an output into a double for use in training.By convention
Event.EventType.EXPECTED
is 1.0, other events are -1.0.- Parameters:
output
- The output to convert.- Returns:
- The double value.
-