Permalink
Browse files

ENH: Make forest prediction code more robust to mutations of the esti…

…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...
1 parent 2f998ca commit 8ad2f5ea8a01a1f33b0acf78bbe7b95c53a6afa4 @ogrisel ogrisel committed Oct 30, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 sklearn/ensemble/forest.py
@@ -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)):
@@ -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

0 comments on commit 8ad2f5e

Please sign in to comment.