Skip to content

Commit

Permalink
ENH: Make forest prediction code more robust to mutations of the esti…
Browse files Browse the repository at this point in the history
…mators list

This can be useful to quickly study the impact of the size of the forest by
subsampling from it for instance.
  • Loading branch information
ogrisel committed Oct 30, 2013
1 parent 2f998ca commit 8ad2f5e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sklearn/ensemble/forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def predict_proba(self, X):
for j in xrange(1, len(all_proba)):
proba += all_proba[j]

proba /= self.n_estimators
proba /= len(self.estimators_)

else:
for j in xrange(1, len(all_proba)):
Expand Down Expand Up @@ -572,7 +572,7 @@ def predict(self, X):
for i in range(n_jobs))

# Reduce
y_hat = sum(all_y_hat) / self.n_estimators
y_hat = sum(all_y_hat) / len(self.estimators_)

return y_hat

Expand Down

0 comments on commit 8ad2f5e

Please sign in to comment.