Class RandomForest

java.lang.Object
ai.beestream.jitnn.ml.RandomForest

public final class RandomForest extends Object
Random forests (Breiman, 2001) and single decision trees on binned features: trees grown on bootstrap samples (weights drawn on the host) with a random subset of the features at each split, predictions averaged. Classification splits on Gini impurity, regression on squared error. A single tree is a forest of one tree without bootstrap or feature sampling, after scikit-learn's DecisionTreeClassifier and DecisionTreeRegressor; thresholds lie on bin edges (maxBins per feature).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    What the forest predicts.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RandomForest(RandomForest.Task task, int trees, int maxDepth, int minSamplesLeaf, int maxFeatures, int maxBins, boolean bootstrap, long seed)
    maxFeatures <= 0: sqrt(F) for classification, all for regression (scikit-learn's defaults).
    RandomForest(RandomForest.Task task, int trees, int maxDepth, long seed)
    A forest of trees bootstrapped trees of depth at most maxDepth, one sample per leaf at least, scikit-learn's default feature subsets, 128 bins.
  • Method Summary

    Modifier and Type
    Method
    Description
    fit(Tensor x, int[] y)
    Fits a classifier to samples x [n, features] and labels y.
    fit(Tensor x, Tensor y)
    Regression targets [n].
    int[]
    The label with the highest averaged probability, for each sample.
    Mean of the trees' leaf values: class probabilities [m, c] or predictions [m, 1].
    tree(RandomForest.Task task, int maxDepth, int minSamplesLeaf)
    One decision tree.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomForest

      public RandomForest(RandomForest.Task task, int trees, int maxDepth, int minSamplesLeaf, int maxFeatures, int maxBins, boolean bootstrap, long seed)
      maxFeatures <= 0: sqrt(F) for classification, all for regression (scikit-learn's defaults).
    • RandomForest

      public RandomForest(RandomForest.Task task, int trees, int maxDepth, long seed)
      A forest of trees bootstrapped trees of depth at most maxDepth, one sample per leaf at least, scikit-learn's default feature subsets, 128 bins.
  • Method Details

    • tree

      public static RandomForest tree(RandomForest.Task task, int maxDepth, int minSamplesLeaf)
      One decision tree.
    • fit

      public RandomForest fit(Tensor x, int[] y)
      Fits a classifier to samples x [n, features] and labels y.
    • fit

      public RandomForest fit(Tensor x, Tensor y)
      Regression targets [n].
    • predictValues

      public Tensor predictValues(Tensor x)
      Mean of the trees' leaf values: class probabilities [m, c] or predictions [m, 1].
    • predict

      public int[] predict(Tensor x)
      The label with the highest averaged probability, for each sample.