xgboost icon indicating copy to clipboard operation
xgboost copied to clipboard

Seems getting info of 'group' slot doesn't works (in R)

Open BlindApe opened this issue 12 years ago • 4 comments

require(xgboost) data(agaricus.train, package='xgboost') train <- agaricus.train group = rep(seq(1:3), length.out = length(train[[1]])) dtrain <- xgb.DMatrix(data = train$data, label = train$label, group = group)

works

labels <- getinfo(dtrain, 'label') head(labels) [1] 1 0 0 1 0 0

doesn't works

groups <- getinfo(dtrain, 'group') Error en .local(object, ...) : xgb.getinfo: unknown info name group

low level works

labels <- .Call("XGDMatrixGetInfo_R", dtrain, 'label', PACKAGE = "xgboost") head(labels) [1] 1 0 0 1 0 0

low level doesn't works

groups <- .Call("XGDMatrixGetInfo_R", dtrain, 'group', PACKAGE = "xgboost") Error: unknown field group

explicit setinfo

setinfo(dtrain, 'group', group) [1] TRUE groups <- .Call("XGDMatrixGetInfo_R", dtrain, 'group', PACKAGE = "xgboost") Error: unknown field group

BlindApe avatar Sep 24 '14 18:09 BlindApe

Yes, the group information was not accessible in current version. The reason is internal data structure of group is not exactly what you set. It is the only information you can not access but can set

On Wed, Sep 24, 2014 at 11:29 AM, Blind Ape [email protected] wrote:

require(xgboost) data(agaricus.train, package='xgboost') train <- agaricus.train group = rep(seq(1:3), length.out = length(train[[1]])) dtrain <- xgb.DMatrix(data = train$data, label = train$label, group = group) works

labels <- getinfo(dtrain, 'label') head(labels) [1] 1 0 0 1 0 0 doesn't works

groups <- getinfo(dtrain, 'group') Error en .local(object, ...) : xgb.getinfo: unknown info name group low level works

labels <- .Call("XGDMatrixGetInfo_R", dtrain, 'label', PACKAGE = "xgboost") head(labels) [1] 1 0 0 1 0 0 low level doesn't works

groups <- .Call("XGDMatrixGetInfo_R", dtrain, 'group', PACKAGE = "xgboost") Error: unknown field group explicit setinfo

setinfo(dtrain, 'group', group) [1] TRUE groups <- .Call("XGDMatrixGetInfo_R", dtrain, 'group', PACKAGE = "xgboost") Error: unknown field group

— Reply to this email directly or view it on GitHub https://github.com/tqchen/xgboost/issues/83.

tqchen avatar Sep 24 '14 19:09 tqchen

See updated customized obj script, where you will be able to set anything to DMatrix for customized function to use

https://github.com/tqchen/xgboost/blob/master/R-package/demo/custom_objective.R

tqchen avatar Oct 01 '14 16:10 tqchen

@tqchen any change for getinfo "group" ? I just tried with no success (by modifying the R source code) :-(

> getinfo(dtrain, 'group')
Error in getinfo.xgb.DMatrix(dtrain, "group") : 
  [16:58:17] ../..//amalgamation/../src/c_api/c_api.cc:488: Unknown float field name group

Stack trace returned 10 entries:
[bt] (0) /home/benesty_local/R/x86_64-pc-linux-gnu-library/3.4/xgboost/libs/xgboost.so(_ZN4dmlc15LogMessageFatalD1Ev+0x36) [0x7fc23a9d9996]
[bt] (1) /home/benesty_local/R/x86_64-pc-linux-gnu-library/3.4/xgboost/libs/xgboost.so(XGDMatrixGetFloatInfo+0x10e) [0x7fc23a9e04fe]
[bt] (2) /home/benesty_local/R/x86_64-pc-linux-gnu-library/3.4/xgboost/libs/xgboost.so(XGDMatrixGetInfo_R+0x51) [0x7fc23a9d6671]
[bt] (3) /usr/lib/R/lib/libR.so(+0xd2d3c) [0x7fc263f52d3c]
[bt] (4) /usr/lib/R/lib/libR.so(Rf_eval+0x7c5) [0x7fc263f8fab5]
[bt] (5) /usr/lib/R/lib/libR.so(+0x1136a6) [0x7fc263f936a6]
[bt] (6) /usr/lib/R/lib/libR.so(Rf_eval+0x5a0) [0x7fc263f8f890]
[bt] (7) /usr/lib/R/lib/libR.so(+0x112538) [0x7fc263f92538]
[bt] (8) /usr/lib/R/lib/libR.so(Rf_eval+0x5a0) [0x7fc263f8f890]
[bt] (9) /usr/lib/R/lib/libR.so(Rf_eval+0x5a0) [0x7fc263f8f890]

pommedeterresautee avatar May 30 '17 15:05 pommedeterresautee

linked to https://github.com/dmlc/xgboost/issues/1431 https://github.com/dmlc/xgboost/issues/574#issuecomment-161806666 (closure solution)

pommedeterresautee avatar May 30 '17 15:05 pommedeterresautee