jmquintana79
2/23/2018 - 8:54 AM

custom Scikit scores

Make custom scores to be used in Scikit tools as for example "cross_val_score" or "GridSearchCV".

# make custom score for classification problem
from sklearn.metrics import fbeta_score, make_scorer
ftwo_scorer = make_scorer(fbeta_score, beta=2)

# using this score for GridSearchCV optimization activity
from sklearn.model_selection import GridSearchCV
from sklearn.svm import LinearSVC
grid = GridSearchCV(LinearSVC(), param_grid={'C': [1, 10]},scoring=ftwo_scorer)