Documentation of 'jsat.classifiers.boosting.Stacking' Java class
Stacking
jsat.classifiers.boosting

Class Stacking

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Classifier, Regressor


    public class Stacking
    extends java.lang.Object
    implements Classifier, Regressor
    This provides an implementation of the Stacking ensemble method. Stacking learns several base classifiers and a top level classifier learns to predict the target based on the outputs of all the ensambled models. Historically a linear model (such as LinearBatch) is used, which translates to learning a weighted vote of the classifier outputs. However any classifier may be used so long as it supports the desired target type.

    Note, that Stacking tends to work best when the base classifiers produce reasonable probability estimates.
    Stacking supports weighted data instances if the aggregating model does.
    See: Wolpert, D. H. (1992). Stacked generalization. Neural Networks, 5, 241–259.
    See Also:
    Serialized Form
    • Constructor Detail

      • Stacking

        public Stacking(int folds,
                        Classifier aggregatingClassifier,
                        java.util.List<Classifier> baseClassifiers)
        Creates a new Stacking classifier
        Parameters:
        folds - the number of cross validation folds for learning the base model
        aggregatingClassifier - the classifier used to merge the results of all the input classifiers
        baseClassifiers - the list of base classifiers to ensemble
      • Stacking

        public Stacking(int folds,
                        Classifier aggregatingClassifier,
                        Classifier... baseClassifiers)
        Creates a new Stacking classifier
        Parameters:
        folds - the number of cross validation folds for learning the base model
        aggregatingClassifier - the classifier used to merge the results of all the input classifiers
        baseClassifiers - the array of base classifiers to ensemble
      • Stacking

        public Stacking(Classifier aggregatingClassifier,
                        java.util.List<Classifier> baseClassifiers)
        Creates a new Stacking classifier that uses 3 folds of cross validation
        Parameters:
        aggregatingClassifier - the classifier used to merge the results of all the input classifiers
        baseClassifiers - the list of base classifiers to ensemble
      • Stacking

        public Stacking(Classifier aggregatingClassifier,
                        Classifier... baseClassifiers)
        Creates a new Stacking classifier that uses 3 folds of cross validation
        Parameters:
        aggregatingClassifier - the classifier used to merge the results of all the input classifiers
        baseClassifiers - the array of base classifiers to ensemble
      • Stacking

        public Stacking(int folds,
                        Regressor aggregatingRegressor,
                        java.util.List<Regressor> baseRegressors)
        Creates a new Stacking regressor
        Parameters:
        folds - the number of cross validation folds for learning the base model
        aggregatingRegressor - the regressor used to merge the results of all the input classifiers
        baseRegressors - the list of base regressors to ensemble
      • Stacking

        public Stacking(int folds,
                        Regressor aggregatingRegressor,
                        Regressor... baseRegressors)
        Creates a new Stacking regressor
        Parameters:
        folds - the number of cross validation folds for learning the base model
        aggregatingRegressor - the regressor used to merge the results of all the input classifiers
        baseRegressors - the array of base regressors to ensemble
      • Stacking

        public Stacking(Regressor aggregatingRegressor,
                        java.util.List<Regressor> baseRegressors)
        Creates a new Stacking regressor that uses 3 folds of cross validation
        Parameters:
        aggregatingRegressor - the regressor used to merge the results of all the input classifiers
        baseRegressors - the list of base regressors to ensemble
      • Stacking

        public Stacking(Regressor aggregatingRegressor,
                        Regressor... baseRegressors)
        Creates a new Stacking regressor that uses 3 folds of cross validation
        Parameters:
        aggregatingRegressor - the regressor used to merge the results of all the input classifiers
        baseRegressors - the array of base regressors to ensemble
      • Stacking

        public Stacking(Stacking toCopy)
        Copy constructor
        Parameters:
        toCopy - the object to copy
    • Method Detail

      • setFolds

        public void setFolds(int folds)
        Sets the number of folds of cross validation to use when creating the new set of weights that will be feed into the aggregating model.
        Note that the number of folds may be 1, and will run significantly faster since models do not need to be re-trained. However it will be more prone to overfitting.
        Parameters:
        folds - the number of cross validation folds to use
      • getFolds

        public int getFolds()
        Returns:
        the number of CV folds used for training
      • classify

        public CategoricalResults classify(DataPoint data)
        Description copied from interface: Classifier
        Performs classification on the given data point.
        Specified by:
        classify in interface Classifier
        Parameters:
        data - the data point to classify
        Returns:
        the results of the classification.
      • train

        public void train(ClassificationDataSet dataSet,
                          boolean parallel)
        Description copied from interface: Classifier
        Trains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.
        Specified by:
        train in interface Classifier
        Parameters:
        dataSet - the data set to train on
        parallel - true if multiple threads should be used to train the model. false if it should be done in a single threaded manner.
      • supportsWeightedData

        public boolean supportsWeightedData()
        Description copied from interface: Classifier
        Indicates whether the model knows how to train using weighted data points. If it does, the model will train assuming the weights. The values returned by this method may change depending on the parameters set for the model.
        Specified by:
        supportsWeightedData in interface Classifier
        Specified by:
        supportsWeightedData in interface Regressor
        Returns:
        true if the model supports weighted data, false otherwise

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.