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

Method _vote

numpy_ml/trees/rf.py:78–99  ·  view source on GitHub ↗

Return the aggregated prediction across all trees in the RF for each problem. Parameters ---------- predictions : :py:class:`ndarray ` of shape `(n_trees, N)` The array of predictions from each decision tree in the RF for each

(self, predictions)

Source from the content-addressed store, hash-verified

76 return self._vote(tree_preds)
77
78 def _vote(self, predictions):
79 """
80 Return the aggregated prediction across all trees in the RF for each problem.
81
82 Parameters
83 ----------
84 predictions : :py:class:`ndarray <numpy.ndarray>` of shape `(n_trees, N)`
85 The array of predictions from each decision tree in the RF for each
86 of the `N` problems in `X`.
87
88 Returns
89 -------
90 y_pred : :py:class:`ndarray <numpy.ndarray>` of shape `(N,)`
91 If classifier is True, the class label predicted by the majority of
92 the decision trees for each problem in `X`. If classifier is False,
93 the average prediction across decision trees on each problem.
94 """
95 if self.classifier:
96 out = [np.bincount(x).argmax() for x in predictions.T]
97 else:
98 out = [np.mean(x) for x in predictions.T]
99 return np.array(out)

Callers 1

predictMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected