flennerhag / mlens

ML-Ensemble – high performance ensemble learning
http://ml-ensemble.com
MIT License
843 stars 108 forks source link

Error while using AUC-ROC as the scoring metric #91

Closed shubhamjn1 closed 6 years ago

shubhamjn1 commented 6 years ago

While adding any model in the ensemble layer, it is throwing an error as:

RuntimeError: Cannot clone object Learner(attr='predict', backend='threading', dtype=<class 'numpy.float32'>, estimator=RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini', max_depth=6, max_features='sqrt', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, min_samples_leaf=1, min_samples_split=2, min_weight_fraction_leaf=0.0, n_estimators=300, n_jobs=1, oob_score=True, random_state=1, verbose=0, warm_start=False), indexer=FoldIndex(X=None, folds=2, raise_on_exception=True), n_jobs=-1, name='randomforestclassifier', preprocess=None, proba=False, raise_on_exception=True, scorer=make_scorer(roc_auc_score)), as the constructor does not seem to set parameter scorer

flennerhag commented 6 years ago

In the ensemble layers the scorer is expected to be a function: ensemble(scorer=roc_auc_score).

You should only use make_scorer for the Evaluator.

shubhamjn1 commented 6 years ago

Yes, I am using it the same way.

from mlens.metrics import make_scorer
auc_scorer = make_scorer(roc_auc_score, greater_is_better=True)

ensemble = SuperLearner(scorer= auc_scorer , random_state= 2, verbose =2)
flennerhag commented 6 years ago

Don't use make_scorer:

from sklearn.metrics import roc_auc_score

ensemble = SuperLearner(..., scorer=roc_auc_score)