MCPcopy Create free account
hub / github.com/rushter/MLAlgorithms / __init__

Method __init__

mla/ensemble/random_forest.py:62–85  ·  view source on GitHub ↗
(
        self,
        n_estimators=10,
        max_features=None,
        min_samples_split=10,
        max_depth=None,
        criterion="entropy",
    )

Source from the content-addressed store, hash-verified

60
61class RandomForestClassifier(RandomForest):
62 def __init__(
63 self,
64 n_estimators=10,
65 max_features=None,
66 min_samples_split=10,
67 max_depth=None,
68 criterion="entropy",
69 ):
70 super(RandomForestClassifier, self).__init__(
71 n_estimators=n_estimators,
72 max_features=max_features,
73 min_samples_split=min_samples_split,
74 max_depth=max_depth,
75 criterion=criterion,
76 )
77
78 if criterion == "entropy":
79 self.criterion = information_gain
80 else:
81 raise ValueError()
82
83 # Initialize empty trees
84 for _ in range(self.n_estimators):
85 self.trees.append(Tree(criterion=self.criterion))
86
87 def _predict(self, X=None):
88 y_shape = np.unique(self.y).shape[0]

Callers

nothing calls this directly

Calls 2

TreeClass · 0.90
__init__Method · 0.45

Tested by

no test coverage detected