public class RandomForest extends java.lang.Object implements IClassifier, java.io.Serializable
Each tree is constructed using the following algorithm:
| Modifier and Type | Class and Description |
|---|---|
static class |
RandomForest.RandomSelection
Method for choose number of random feature.
|
| Constructor and Description |
|---|
RandomForest()
Initializes a new instance of the RandomForest class.
|
RandomForest(DecisionVariable[] attributes)
Initializes a new instance of the RandomForest class.
|
RandomForest(DecisionVariable[] attributes,
int T)
Initializes a new instance of the RandomForest class.
|
RandomForest(DecisionVariable[] attributes,
int T,
int M)
Initializes a new instance of the RandomForest class.
|
RandomForest(DecisionVariable[] attributes,
int T,
int M,
DecisionTree.SplitRule rule)
Initializes a new instance of the RandomForest class.
|
RandomForest(DecisionVariable[] attributes,
int T,
RandomForest.RandomSelection randomSelection)
Initializes a new instance of the RandomForest class.
|
RandomForest(DecisionVariable[] attributes,
int T,
RandomForest.RandomSelection randomSelection,
DecisionTree.SplitRule rule)
Initializes a new instance of the RandomForest class.
|
RandomForest(int T)
Initializes a new instance of the RandomForest class.
|
RandomForest(int T,
int M)
Initializes a new instance of the RandomForest class.
|
RandomForest(int T,
int M,
DecisionTree.SplitRule rule)
Initializes a new instance of the RandomForest class.
|
RandomForest(int T,
RandomForest.RandomSelection randomSelection)
Initializes a new instance of the RandomForest class.
|
RandomForest(int T,
RandomForest.RandomSelection randomSelection,
DecisionTree.SplitRule rule)
Initializes a new instance of the RandomForest class.
|
| Modifier and Type | Method and Description |
|---|---|
IClassifier |
clone()
Clone of the object.
|
double |
error()
Returns the out-of-bag estimation of error rate.
|
DecisionTree.SplitRule |
getRule()
Get split rule.
|
double[] |
importance()
Returns the variable importance.
|
void |
Learn(DatasetClassification dataset)
Learn from a dataset.
|
void |
Learn(double[][] input,
int[] output)
Learn.
|
int |
Predict(double[] feature)
Predict.
|
int |
Predict(double[] feature,
double[] posteriori) |
void |
setRule(DecisionTree.SplitRule rule)
Set split rule.
|
int |
size()
Returns the number of trees in the model.
|
void |
trim(int T)
Trims the tree model set to a smaller size in case of over-fitting.
|
public RandomForest()
public RandomForest(int T)
T - the number of trees.public RandomForest(int T,
int M)
T - the number of trees.M - the number of random selected features to be used to determine
the decision at a node of the tree. floor(sqrt(dim)) seems to give
generally good performance, where dim is the number of variables.public RandomForest(int T,
int M,
DecisionTree.SplitRule rule)
T - the number of trees.M - the number of random selected features to be used to determine
the decision at a node of the tree. floor(sqrt(dim)) seems to give
generally good performance, where dim is the number of variables.rule - Split rule decision tree.public RandomForest(int T,
RandomForest.RandomSelection randomSelection)
T - the number of trees.randomSelection - the number of random selected features.public RandomForest(int T,
RandomForest.RandomSelection randomSelection,
DecisionTree.SplitRule rule)
T - the number of trees.randomSelection - the number of random selected features.public RandomForest(DecisionVariable[] attributes)
attributes - the attribute properties.public RandomForest(DecisionVariable[] attributes, int T)
attributes - the attribute properties.T - the number of trees.public RandomForest(DecisionVariable[] attributes, int T, int M)
attributes - the attribute properties.T - the number of trees.M - the number of random selected features to be used to determine
the decision at a node of the tree. floor(sqrt(dim)) seems to give
generally good performance, where dim is the number of variables.public RandomForest(DecisionVariable[] attributes, int T, int M, DecisionTree.SplitRule rule)
attributes - the attribute properties.T - the number of trees.M - the number of random selected features.rule - Split rule decision tree.public RandomForest(DecisionVariable[] attributes, int T, RandomForest.RandomSelection randomSelection)
attributes - the attribute properties.T - the number of trees.randomSelection - The method for create random selected features to be used to determine
the decision at a node of the tree. floor(sqrt(dim)) seems to give
generally good performance, where dim is the number of variables.public RandomForest(DecisionVariable[] attributes, int T, RandomForest.RandomSelection randomSelection, DecisionTree.SplitRule rule)
attributes - the attribute properties.T - the number of trees.randomSelection - The method for create random selected features to be used to determine
the decision at a node of the tree. floor(sqrt(dim)) seems to give
generally good performance, where dim is the number of variables.rule - SplitRule decision tree.public double error()
public double[] importance()
public int size()
public DecisionTree.SplitRule getRule()
public void setRule(DecisionTree.SplitRule rule)
rule - Split rule.public void trim(int T)
T - the new (smaller) size of tree model set.public void Learn(DatasetClassification dataset)
IClassifierLearn in interface IClassifierdataset - Dataset.public void Learn(double[][] input,
int[] output)
IClassifierLearn in interface IClassifierinput - Matrix of features.output - Labels.public int Predict(double[] feature)
IClassifierPredict in interface IClassifierfeature - Feature.public int Predict(double[] feature,
double[] posteriori)
public IClassifier clone()
IClassifierclone in interface IClassifierclone in class java.lang.Object