I am doing a churn analysis. I used
randomcv = RandomizedSearchCV(estimator=clf,param_distributions = params_grid,
cv=kfoldcv,n_iter=100, n_jobs=-1, scoring='roc_auc')
and everything was fine, but then, I tried with a custom scoring function this way
def gain_fn(y_true, y_prob):
tp = np.where((y_prob>=0.025) & (y_true==1), 40000, 0)
fp = np.where((y_prob>=0.025) & (y_true==0), -1000, 0)
return np.sum([tp,fp])
scorer_fn = make_scorer(gain_fn, greater_is_better = True, needs_proba=True)
randomcv = RandomizedSearchCV(estimator=clf,param_distributions = params_grid,
cv=kfoldcv,n_iter=100, n_jobs=-1, scoring=scorer_fn)
but I want to make a calculation inside of gain_fn with a certain value of the class (it has 3 possible values). How to select the correct y_pred parameter? Any suggestion? Thank you!