public class LibLinearAnomalyTrainer extends LibLinearTrainer<Event>
Trainer
which wraps a liblinear-java anomaly detection trainer using a one-class SVM.
Note the train method is synchronized on LibLinearTrainer.class
due to a global RNG in liblinear-java.
This is insufficient to ensure reproducibility if liblinear-java is used directly in the same JVM as Tribuo, but
avoids locking on classes Tribuo does not control.
See:
Fan RE, Chang KW, Hsieh CJ, Wang XR, Lin CJ. "LIBLINEAR: A library for Large Linear Anomaly" Journal of Machine Learning Research, 2008.and for the original algorithm:
Cortes C, Vapnik V. "Support-Vector Networks" Machine Learning, 1995.
cost, epsilon, libLinearParams, maxIterations, terminationCriterion, trainerType
DEFAULT_SEED
Constructor and Description |
---|
LibLinearAnomalyTrainer()
Creates a trainer using the default values (type:ONECLASS_SVM, cost:1, maxIterations:1000, terminationCriterion:0.1, nu:0.5).
|
LibLinearAnomalyTrainer(double nu)
Creates a trainer using the default values (type:ONECLASS_SVM, cost:1, maxIterations:1000, terminationCriterion:0.1) and the specified nu.
|
LibLinearAnomalyTrainer(LinearAnomalyType trainerType,
double cost,
double terminationCriterion,
double nu)
Creates a trainer for a LibLinearAnomalyModel.
|
LibLinearAnomalyTrainer(LinearAnomalyType trainerType,
double cost,
int maxIterations,
double terminationCriterion,
double nu)
Creates a trainer for a LibLinear model
|
Modifier and Type | Method and Description |
---|---|
protected LibLinearModel<Event> |
createModel(ModelProvenance provenance,
ImmutableFeatureMap featureIDMap,
ImmutableOutputInfo<Event> outputIDInfo,
List<de.bwaldvogel.liblinear.Model> models)
Construct the appropriate subtype of LibLinearModel for the prediction task.
|
protected com.oracle.labs.mlrg.olcut.util.Pair<de.bwaldvogel.liblinear.FeatureNode[][],double[][]> |
extractData(Dataset<Event> data,
ImmutableOutputInfo<Event> outputInfo,
ImmutableFeatureMap featureMap)
Extracts the features and
Output s in LibLinear's format. |
void |
postConfig()
Used by the OLCUT configuration system, and should not be called by external code.
|
protected de.bwaldvogel.liblinear.Parameter |
setupParameters(ImmutableOutputInfo<Event> labelIDMap)
Constructs the parameters.
|
protected List<de.bwaldvogel.liblinear.Model> |
trainModels(de.bwaldvogel.liblinear.Parameter curParams,
int numFeatures,
de.bwaldvogel.liblinear.FeatureNode[][] features,
double[][] outputs)
Train all the liblinear instances necessary for this dataset.
|
exampleToNodes, getInvocationCount, getProvenance, toString, train, train
public LibLinearAnomalyTrainer()
public LibLinearAnomalyTrainer(double nu)
nu
- The nu parameter in the one-class SVM.public LibLinearAnomalyTrainer(LinearAnomalyType trainerType, double cost, double terminationCriterion, double nu)
trainerType
- Loss function and optimisation method combination.cost
- Cost penalty for each incorrectly classified training point.terminationCriterion
- How close does the optimisation function need to be before terminating that subproblem (usually set to 0.1).nu
- The nu parameter in the one-class SVM.public LibLinearAnomalyTrainer(LinearAnomalyType trainerType, double cost, int maxIterations, double terminationCriterion, double nu)
trainerType
- Loss function and optimisation method combination.cost
- Cost penalty for each incorrectly classified training point.maxIterations
- The maximum number of dataset iterations.terminationCriterion
- How close does the optimisation function need to be before terminating that subproblem (usually set to 0.1).nu
- The nu parameter in the one-class SVM.public void postConfig()
postConfig
in interface com.oracle.labs.mlrg.olcut.config.Configurable
postConfig
in class LibLinearTrainer<Event>
protected de.bwaldvogel.liblinear.Parameter setupParameters(ImmutableOutputInfo<Event> labelIDMap)
LibLinearTrainer
setupParameters
in class LibLinearTrainer<Event>
labelIDMap
- The output info.protected List<de.bwaldvogel.liblinear.Model> trainModels(de.bwaldvogel.liblinear.Parameter curParams, int numFeatures, de.bwaldvogel.liblinear.FeatureNode[][] features, double[][] outputs)
LibLinearTrainer
trainModels
in class LibLinearTrainer<Event>
curParams
- The LibLinear parameters.numFeatures
- The number of features in this dataset.features
- The features themselves.outputs
- The outputs.protected LibLinearModel<Event> createModel(ModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<Event> outputIDInfo, List<de.bwaldvogel.liblinear.Model> models)
LibLinearTrainer
createModel
in class LibLinearTrainer<Event>
provenance
- The model provenance.featureIDMap
- The feature id map.outputIDInfo
- The output id info.models
- The list of linear models.protected com.oracle.labs.mlrg.olcut.util.Pair<de.bwaldvogel.liblinear.FeatureNode[][],double[][]> extractData(Dataset<Event> data, ImmutableOutputInfo<Event> outputInfo, ImmutableFeatureMap featureMap)
LibLinearTrainer
Output
s in LibLinear's format.extractData
in class LibLinearTrainer<Event>
data
- The input data.outputInfo
- The output info.featureMap
- The feature info.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.