Class LibSVMRegressionTrainer

java.lang.Object
org.tribuo.common.libsvm.LibSVMTrainer<Regressor>
org.tribuo.regression.libsvm.LibSVMRegressionTrainer
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<TrainerProvenance>, Trainer<Regressor>

public class LibSVMRegressionTrainer extends LibSVMTrainer<Regressor>
A trainer for regression models that uses LibSVM. Trains an independent model for each output dimension.

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-svr 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.
 
  • Constructor Details

    • LibSVMRegressionTrainer

      protected LibSVMRegressionTrainer()
      For olcut.
    • LibSVMRegressionTrainer

      public LibSVMRegressionTrainer(SVMParameters<Regressor> parameters)
      Constructs a LibSVMRegressionTrainer using the supplied parameters without standardizing the regression variables.
      Parameters:
      parameters - The SVM parameters.
    • LibSVMRegressionTrainer

      public LibSVMRegressionTrainer(SVMParameters<Regressor> parameters, boolean standardize)
      Constructs a LibSVMRegressionTrainer using the supplied parameters and Trainer.DEFAULT_SEED.
      Parameters:
      parameters - The SVM parameters.
      standardize - Standardize the regression outputs before training.
    • LibSVMRegressionTrainer

      public LibSVMRegressionTrainer(SVMParameters<Regressor> parameters, boolean standardize, long seed)
      Constructs a LibSVMRegressionTrainer using the supplied parameters and seed.
      Parameters:
      parameters - The SVM parameters.
      standardize - Standardize the regression outputs before training.
      seed - The RNG seed for LibSVM's internal RNG.
  • Method Details

    • postConfig

      public void postConfig()
      Used by the OLCUT configuration system, and should not be called by external code.
      Specified by:
      postConfig in interface com.oracle.labs.mlrg.olcut.config.Configurable
      Overrides:
      postConfig in class LibSVMTrainer<Regressor>
    • createModel

      protected LibSVMModel<Regressor> createModel(ModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<Regressor> 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 class LibSVMTrainer<Regressor>
      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, SplittableRandom localRNG)
      Description copied from class: LibSVMTrainer
      Train all the LibSVM instances necessary for this dataset.
      Specified by:
      trainModels in class LibSVMTrainer<Regressor>
      Parameters:
      curParams - The LibSVM parameters.
      numFeatures - The number of features in this dataset.
      features - The features themselves.
      outputs - The outputs.
      localRNG - The RNG to use for seeding LibSVM's RNG.
      Returns:
      A list of LibSVM models.
    • extractData

      protected com.oracle.labs.mlrg.olcut.util.Pair<libsvm.svm_node[][],double[][]> extractData(Dataset<Regressor> data, ImmutableOutputInfo<Regressor> outputInfo, ImmutableFeatureMap featureMap)
      Description copied from class: LibSVMTrainer
      Extracts the features and Outputs in LibSVM's format.
      Specified by:
      extractData in class LibSVMTrainer<Regressor>
      Parameters:
      data - The input data.
      outputInfo - The output info.
      featureMap - The feature info.
      Returns:
      The features and outputs.