Class LibLinearRegressionTrainer
java.lang.Object
org.tribuo.common.liblinear.LibLinearTrainer<Regressor>
org.tribuo.regression.liblinear.LibLinearRegressionTrainer
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable,com.oracle.labs.mlrg.olcut.provenance.Provenancable<TrainerProvenance>,Trainer<Regressor>
A
Trainer which wraps a liblinear-java regression trainer.
This generates an independent liblinear model for each regression dimension.
See:
Fan RE, Chang KW, Hsieh CJ, Wang XR, Lin CJ. "LIBLINEAR: A library for Large Linear Classification" Journal of Machine Learning Research, 2008.and for the original algorithm:
Cortes C, Vapnik V. "Support-Vector Networks" Machine Learning, 1995.
-
Field Summary
Fields inherited from class org.tribuo.common.liblinear.LibLinearTrainer
cost, epsilon, libLinearParams, maxIterations, terminationCriterion, trainerTypeFields inherited from interface org.tribuo.Trainer
DEFAULT_SEED -
Constructor Summary
ConstructorsConstructorDescriptionCreates a trainer using the default values (L2R_L2LOSS_SVR, 1, 1000, 0.1, 0.1).LibLinearRegressionTrainer(LinearRegressionType trainerType) LibLinearRegressionTrainer(LinearRegressionType trainerType, double cost, int maxIterations, double terminationCriterion, double epsilon) Creates a trainer for a LibLinear model -
Method Summary
Modifier and TypeMethodDescriptionprotected LibLinearModel<Regressor> createModel(ModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<Regressor> 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<Regressor> data, ImmutableOutputInfo<Regressor> outputInfo, ImmutableFeatureMap featureMap) Extracts the features andOutputs in LibLinear's format.voidUsed by the OLCUT configuration system, and should not be called by external code.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.Methods inherited from class org.tribuo.common.liblinear.LibLinearTrainer
exampleToNodes, getInvocationCount, getProvenance, setupParameters, toString, train
-
Constructor Details
-
LibLinearRegressionTrainer
public LibLinearRegressionTrainer()Creates a trainer using the default values (L2R_L2LOSS_SVR, 1, 1000, 0.1, 0.1). -
LibLinearRegressionTrainer
-
LibLinearRegressionTrainer
public LibLinearRegressionTrainer(LinearRegressionType trainerType, double cost, int maxIterations, double terminationCriterion, double epsilon) Creates a trainer for a LibLinear model- Parameters:
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).epsilon- The insensitivity of the regression loss to small differences.
-
-
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 classLibLinearTrainer<Regressor>
-
trainModels
protected List<de.bwaldvogel.liblinear.Model> trainModels(de.bwaldvogel.liblinear.Parameter curParams, int numFeatures, de.bwaldvogel.liblinear.FeatureNode[][] features, double[][] outputs) Description copied from class:LibLinearTrainerTrain all the liblinear instances necessary for this dataset.- Specified by:
trainModelsin classLibLinearTrainer<Regressor>- 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.
-
createModel
protected LibLinearModel<Regressor> createModel(ModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<Regressor> outputIDInfo, List<de.bwaldvogel.liblinear.Model> models) Description copied from class:LibLinearTrainerConstruct the appropriate subtype of LibLinearModel for the prediction task.- Specified by:
createModelin classLibLinearTrainer<Regressor>- Parameters:
provenance- The model provenance.featureIDMap- The feature id map.outputIDInfo- The output id info.models- The list of linear models.- Returns:
- An implementation of LibLinearModel.
-
extractData
protected com.oracle.labs.mlrg.olcut.util.Pair<de.bwaldvogel.liblinear.FeatureNode[][], double[][]> extractData(Dataset<Regressor> data, ImmutableOutputInfo<Regressor> outputInfo, ImmutableFeatureMap featureMap) Description copied from class:LibLinearTrainerExtracts the features andOutputs in LibLinear's format.- Specified by:
extractDatain classLibLinearTrainer<Regressor>- Parameters:
data- The input data.outputInfo- The output info.featureMap- The feature info.- Returns:
- The features and outputs.
-