I try to use GridSearchCV to optimize the analysis that I do, and I read that it supports several evaluation methods , and I found an example of this method elsewhere ( example ), but when I try to run GridSearchCV with several evaluation indicators in several formats, which must be supported, this causes an error:
File "/home/graduate/adsherma/miniconda2/envs/testenv/lib/python2.7/site-packages/sklearn/model_selection/_validation.py", line 288, in _score
score = scorer(estimator, X_test, y_test)
TypeError: 'dict' object is not callable
My source code for this:
DF = pd.read_pickle("OutPut/from_ntuples/nominal.pkl")
X = DF[RC.FittableParameters]
y = DF['isSignal']
pipe = Pipeline([
('reduce_dim', SelectKBest()),
('classify', AdaBoostClassifier())
])
BASE_ESTIMATORS = [DecisionTreeClassifier(max_depth=i) for i in range(1, 4)]
N_ESTIMATORS = range(100, 600, 100)
param_grid = [
{
'reduce_dim': [PCA()],
'reduce_dim__n_components': [1,10,20,30,40,50],
'classify__base_estimator': BASE_ESTIMATORS,
'classify__n_estimators': N_ESTIMATORS,
} ,
]
scoring = {'Precision': make_scorer(precision_score),
'Accuracy': make_scorer(accuracy_score)}
grid = GridSearchCV(pipe, cv=5, n_jobs=1,
param_grid=param_grid, verbose=1,
scoring=scoring)
grid.fit(X, y)
The error will be the same if I try a list or tuple, but I complain that lists and tuples are not callable. This is basically a copy inserted from the link link above (cannot be attached because I don't have enough reputation), so I don’t understand a bit where to continue.