I'm using scikit-slearn 0.14 and trying to implement a user defined scoring function for GridSearchCV to evaluate.
def someScore(gtruth, pred):
pred = np.clip(pred, 0, np.inf)
logdif = np.log(1 + gtruth) - np.log(1 + pred)
return sin(np.sqrt(np.mean(np.square(logdif))))
neg_scorefun = make_scorer(lambda x,y:someScore(x,y))
Note: I appended sinus so the score ranks differently than most other scores, just for testing...
Now, if I run
g1=GridSearchCV(KernelDensity(),param_grid,scoring=neg_scorefun).fit(X)
and then
g2=GridSearchCV(KernelDensity(),param_grid).fit(X)
then
print g1.best_score_, g2.best_score_
give me exactly the same result. Also "best_params_" are identical. No matter what I put into the function "someScore", it's always the same. I'd expect the results to differ, considering that I tested "someScore" with fixed values, returned some negative values, used sinus (as in the example above) tried basically all sorts of values derived from "ground truth" and "prediction"...
From the results it appears, that no matter what scoring I use, the scorer is ignored, overwritten, not called, whatever...
What am I missing? Any suggestions?