Package smile.regression
Class RandomForest.Trainer
- java.lang.Object
-
- smile.regression.RegressionTrainer<double[]>
-
- smile.regression.RandomForest.Trainer
-
- Enclosing class:
- RandomForest
public static class RandomForest.Trainer extends RegressionTrainer<double[]>
Trainer for random forest.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RandomForest.Trainer
setMaxNodes(int maxNodes)
Sets the maximum number of leaf nodes.RandomForest.Trainer
setNodeSize(int nodeSize)
Sets the minimum size of leaf nodes.RandomForest.Trainer
setNumRandomFeatures(int mtry)
Sets the number of random selected features for splitting.RandomForest.Trainer
setNumTrees(int ntrees)
Sets the number of trees in the random forest.RandomForest.Trainer
setSamplingRates(double subsample)
Sets the sampling rate.RandomForest
train(double[][] x, double[] y)
Learns a regression model with given training data.-
Methods inherited from class smile.regression.RegressionTrainer
setAttributes
-
-
-
-
Constructor Detail
-
Trainer
public Trainer(int ntrees)
Constructor.- Parameters:
ntrees
- the number of trees.
-
Trainer
public Trainer(Attribute[] attributes, int ntrees)
Constructor.- Parameters:
attributes
- the attributes of independent variable.ntrees
- the number of trees.
-
-
Method Detail
-
setNumTrees
public RandomForest.Trainer setNumTrees(int ntrees)
Sets the number of trees in the random forest.- Parameters:
ntrees
- the number of trees.
-
setNumRandomFeatures
public RandomForest.Trainer setNumRandomFeatures(int mtry)
Sets the number of random selected features for splitting.- Parameters:
mtry
- the number of random selected features to be used to determine the decision at a node of the tree. p/3 seems to give generally good performance, where p is the number of variables.
-
setMaxNodes
public RandomForest.Trainer setMaxNodes(int maxNodes)
Sets the maximum number of leaf nodes.- Parameters:
maxNodes
- the maximum number of leaf nodes.
-
setNodeSize
public RandomForest.Trainer setNodeSize(int nodeSize)
Sets the minimum size of leaf nodes.- Parameters:
nodeSize
- the number of instances in a node below which the tree will not split.
-
setSamplingRates
public RandomForest.Trainer setSamplingRates(double subsample)
Sets the sampling rate.- Parameters:
subsample
- the sampling rate.
-
train
public RandomForest train(double[][] x, double[] y)
Description copied from class:RegressionTrainer
Learns a regression model with given training data.- Specified by:
train
in classRegressionTrainer<double[]>
- Parameters:
x
- the training instances.y
- the training response values.- Returns:
- a trained regression model.
-
-