Documentation of 'jsat.classifiers.trees.DecisionStump' Java class
DecisionStump
jsat.classifiers.trees

Class DecisionStump

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


    public class DecisionStump
    extends java.lang.Object
    implements Classifier, Regressor, Parameterized
    This class is a 1-rule. It creates one rule that is used to classify all inputs, making it a decision tree with only one node. It can be used as a weak learner for ensemble learners, or as the nodes in a true decision tree.

    Categorical values are handled similarly under all circumstances.
    During classification, numeric attributes are separated based on most likely probability into their classes.
    During regression, numeric attributes are done with only binary splits, finding the split that minimizes the total squared error sum.

    The Decision Stump supports missing values in training and prediction.
    See Also:
    Serialized Form
    • Constructor Detail

      • DecisionStump

        public DecisionStump()
        Creates a new decision stump
    • Method Detail

      • setRemoveContinuousAttributes

        public void setRemoveContinuousAttributes(boolean removeContinuousAttributes)
        Unlike categorical values, when a continuous attribute is selected to split on, not all values of the attribute become the same. It can be useful to split on the same attribute multiple times. If set true, continuous attributes will be removed from the options list. Else, they will be left in the options list.
        Parameters:
        removeContinuousAttributes - whether or not to remove continuous attributes on a call to trainC(java.util.List, java.util.Set)
      • setMinResultSplitSize

        public void setMinResultSplitSize(int minResultSplitSize)
        When a split is made, it may be that outliers cause the split to segregate a minority of points from the majority. The min result split size parameter specifies the minimum allowable number of points to end up in one of the splits for it to be admisible for consideration.
        Parameters:
        minResultSplitSize - the minimum result split size to use
      • getMinResultSplitSize

        public int getMinResultSplitSize()
        Returns the minimum result split size that may be considered for use as the attribute to split on.
        Returns:
        the minimum result split size in use
      • getSplittingAttribute

        public int getSplittingAttribute()
        Returns the attribute that this stump has decided to use to compute results. Numeric features start from 0, and categorical features start from the number of numeric features.
        Returns:
        the attribute that this stump has decided to use to compute results.
      • whichPath

        public int whichPath(DataPoint data)
        Determines which split path this data point would follow from this decision stump. Works for both classification and regression.
        Parameters:
        data - the data point in question
        Returns:
        the integer indicating which path to take. -1 returned if stump is not trained
      • getNumberOfPaths

        public int getNumberOfPaths()
        Returns the number of paths that this decision stump leads to. The stump may not ever direct a data point on some of the paths. A result of 1 path means that all data points will be given the same decision, and is generated when the entropy of a set is 0.0.

        -1 is returned for an untrained stump
        Returns:
        the number of paths this decision stump has stored
      • 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.
      • result

        public CategoricalResults result(int i)
        Returns the categorical result of the i'th path.
        Parameters:
        i - the path to get the result for
        Returns:
        the result that would be returned if a data point went down the given path
        Throws:
        java.lang.IndexOutOfBoundsException - if an invalid path is given
        java.lang.NullPointerException - if the stump has not been trained for 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.
      • trainC

        public java.util.List<java.util.List<DataPointPair<java.lang.Integer>>> trainC(java.util.List<DataPointPair<java.lang.Integer>> dataPoints,
                                                                                       java.util.Set<java.lang.Integer> options)
        This is a helper function that does the work of training this stump. It may be called directly by other classes that are creating decision trees to avoid redundant repackaging of lists.
        Parameters:
        dataPoints - the lists of datapoint to train on, paired with the true category of each training point
        options - the set of attributes that this classifier may choose from. The attribute it does choose will be removed from the set.
        Returns:
        the a list of lists, containing all the datapoints that would have followed each path. Useful for training a decision tree
      • trainC

        public java.util.List<java.util.List<DataPointPair<java.lang.Integer>>> trainC(java.util.List<DataPointPair<java.lang.Integer>> dataPoints,
                                                                                       java.util.Set<java.lang.Integer> options,
                                                                                       boolean parallel)
      • trainR

        public java.util.List<java.util.List<DataPointPair<java.lang.Double>>> trainR(java.util.List<DataPointPair<java.lang.Double>> dataPoints,
                                                                                      java.util.Set<java.lang.Integer> options)
      • trainR

        public java.util.List<java.util.List<DataPointPair<java.lang.Double>>> trainR(java.util.List<DataPointPair<java.lang.Double>> dataPoints,
                                                                                      java.util.Set<java.lang.Integer> options,
                                                                                      boolean parallel)
      • 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.