How to use Cohen's Kappa as the evaluation metric in GridSearchCV in Scikit Learn? I have class imbalance in the ratio 1:15 i.e. very low event rate. So to select tuning parameters of GBM in scikit learn I want to use Kappa instead of F1 score. My understanding is Kappa is a better metric than F1 score for class imbalance.

But I couldn't find kappa as an evaluation_metric in scikit learn here 
sklearn.metrics.

Questions


Is there any workaround for including kappa in gridsearchcv?
Is there any other better metric i can use instead of kappa in scikit learn?
Cohen's kappa was introduced in scikit-learn 0.17.

You can wrap it in make_scorer for use in GridSearchCV.

from sklearn.metrics import cohen_kappa_score, make_scorer
from sklearn.grid_search import GridSearchCV
from sklearn.svm import LinearSVC

kappa_scorer = make_scorer(cohen_kappa_score)
grid = GridSearchCV(LinearSVC(), param_grid={'C': [1, 10]}, scoring=kappa_scorer)