xgboost icon indicating copy to clipboard operation
xgboost copied to clipboard

Problem with pairwise in R

Open BlindApe opened this issue 12 years ago • 5 comments

Could someone which have used pairwise in R help me with this message. I don't know what is the problem of group structure.

dTrain <- xgb.DMatrix(dataTrain, label = labelTrain, group = groupTrain, missing = - 9999)

model <- xgb.train(param, dTrain, nTree, watchlist)

Error en xgb.iter.update(bst, dtrain, i - 1, obj) : group structure not consistent with #rows

groupTrain[1:100] [1] 1 1 1 1 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 15 16 16 16 16 17 17 17 17 18 18 18 18 20 20 20 20 21 21 21 21 ........ length(groupTrain) [1] 789032 length(labelTrain) [1] 789032

BlindApe avatar Nov 12 '14 22:11 BlindApe

It is the definition of group. In pairwise ranking. The data in each group need to be in continuous position, and group_array is simply the size of each group. So in your case, it should be 4 4 4 4 4.....

and sum(groupTrain) should equal number of rows

tqchen avatar Nov 12 '14 22:11 tqchen

Thank you very much!

with 'map' metric works (but only with 'nthread' = 1, with more hangs)

with 'auc' I obtain:

Error en xgb.iter.eval(bst, watchlist, i - 1, feval) : AUC: the dataset only contains pos or neg samples

BlindApe avatar Nov 12 '14 23:11 BlindApe

Each rank group must contain examples with both 1(relevant) and 0(not relevant) If some group only contain all 1 or all 0, then it will report such error.

tqchen avatar Nov 12 '14 23:11 tqchen

Just I realized about this, but groups with all 0 or 1 are informative (in a point wise view), is right?

I suspect by this error the auc is computed within each group and then averaged, is right?

BlindApe avatar Nov 12 '14 23:11 BlindApe

The group is used when pairwise rank objective is used, and pairs are only considered within each group. Pairwise rank objective does not consider the group with all 0 or 1s.

Yes. You are right that AUC is computed in each group and averaged. It seems bad to have auc complain about this case, but should return either 1 or 0 for the all 1 case. Rank measure such as map, do take the group of all 1 or all 0

tqchen avatar Nov 13 '14 01:11 tqchen