MCPcopy
hub / github.com/ddbourgin/numpy-ml / fit

Method fit

numpy_ml/trees/rf.py:44–59  ·  view source on GitHub ↗

Create `n_trees`-worth of bootstrapped samples from the training data and use each to fit a separate decision tree.

(self, X, Y)

Source from the content-addressed store, hash-verified

42 self.classifier = classifier
43
44 def fit(self, X, Y):
45 """
46 Create `n_trees`-worth of bootstrapped samples from the training data
47 and use each to fit a separate decision tree.
48 """
49 self.trees = []
50 for _ in range(self.n_trees):
51 X_samp, Y_samp = bootstrap_sample(X, Y)
52 tree = DecisionTree(
53 n_feats=self.n_feats,
54 max_depth=self.max_depth,
55 criterion=self.criterion,
56 classifier=self.classifier,
57 )
58 tree.fit(X_samp, Y_samp)
59 self.trees.append(tree)
60
61 def predict(self, X):
62 """

Callers 2

plotFunction · 0.95
test_RandomForestFunction · 0.95

Calls 3

fitMethod · 0.95
bootstrap_sampleFunction · 0.85
DecisionTreeClass · 0.85

Tested by 1

test_RandomForestFunction · 0.76