Skip to content
Snippets Groups Projects

WIP: Resolve "coherence des arbres de predictions"

Open Charly Lamothe requested to merge 20-coherence-des-arbres-de-predictions into master
1 file
+ 4
6
Compare changes
  • Side-by-side
  • Inline
+ 4
6
@@ -145,16 +145,14 @@ class Trainer(object):
from sklearn.preprocessing import normalize
import itertools
if type(model) in [OmpForestRegressor, SimilarityForestRegressor, KMeansForestRegressor, EnsembleSelectionForestRegressor]:
estimators = model.forest
elif type(model) in [OmpForestBinaryClassifier, OmpForestMulticlassClassifier]:
if type(model) in [OmpForestRegressor, SimilarityForestRegressor, KMeansForestRegressor, EnsembleSelectionForestRegressor,
OmpForestBinaryClassifier, OmpForestMulticlassClassifier]:
estimators = model.forest
estimators = np.asarray(estimators)[model._omp.coef_ != 0]
elif type(model) in [RandomForestRegressor, RandomForestClassifier]:
estimators = model.estimators_
predictions = list()
for ti in estimators:
predictions.append(ti.predict(X))
predictions = np.array([tree.predict(X) for tree in estimators])
predictions = normalize(predictions)
Loading