Lightgbm: How to specify the query/group id column for lambdarank in Python?

Created on 12 Apr 2018  路  1Comment  路  Source: microsoft/LightGBM

I noted there was a "query" parameter, but how could I specify the column id or name in python when my data was constructed from a DataFrame?

Taking the code below as an example, the columns of the trainData is ['qid', 'f1', 'f2', 'f3', 'label'], and the fields is ['qid', 'f1', 'f2', 'f3'], of which the qid is the query/group id, and the f1-f3 are the features. I tried to set the query id in params, but got an error "Lambdarank tasks require query information". So how could I specify the query id in Python? @guolinke

trnDataset = lgb.Dataset(trainData[fields], label = trainData.label)
boosterParam = {'objective' : 'lambdarank',  'metric' : 'ndcg' ,"query":"name:qid"}
booster = lgb.train(boosterParam, trnDataset)

Most helpful comment

you are using the python-package, so you cannot use "query" parameter.
you should use the parameter group when construct lgb.Dataset.
BTW, group is not the group_id/query_id, you should convert it like the query/group file: https://github.com/Microsoft/LightGBM/blob/master/docs/Parameters.rst#query-data

>All comments

you are using the python-package, so you cannot use "query" parameter.
you should use the parameter group when construct lgb.Dataset.
BTW, group is not the group_id/query_id, you should convert it like the query/group file: https://github.com/Microsoft/LightGBM/blob/master/docs/Parameters.rst#query-data

Was this page helpful?
0 / 5 - 0 ratings