I am using LightGBM and would like to use average precision recall as a metric. I tried defining feval:
cv_result = lgb.cv(params=params, train_set=lgb_train, feature_name=Rel_Feat_Names, feval=APS)
where APS defined as:
def APS(preds, train_data):
y_pred_val = []
y_test_val = []
for i, stat in enumerate(train_data.get_label.isnull()):
if ~stat:
y_pred_val.append(preds[i])
y_test_val.append(train_data.get_label[i])
aps = average_precision_score(np.array(y_test_val), np.array(y_pred_val))
return aps
and I get an error:
TypeError: Unknown type of parameter:feval, got:function
I also try to use "MAP" as the metric
cv_result = lgb.cv(params=params, train_set=lgb_train, feature_name=Rel_Feat_Names, "metric="MAP")
but got the following error:
"lightgbm.basic.LightGBMError: For MAP metric, there should be query information"
I can't find what is the query information required.
How can I use feval corrctly and define the query required for "MAP"
Thanks