Only column names are supported for xgb.DMatrix
, thus setting of
row names would have no effect and returned row names would be NULL.
# S3 method for xgb.DMatrix dimnames(x) # S3 method for xgb.DMatrix dimnames(x) <- value
x | object of class |
---|---|
value | a list of two elements: the first one is ignored and the second one is column names |
Generic dimnames
methods are used by colnames
.
Since row names are irrelevant, it is recommended to use colnames
directly.
data(agaricus.train, package='xgboost') train <- agaricus.train dtrain <- xgb.DMatrix(train$data, label=train$label) dimnames(dtrain)#> [[1]] #> NULL #> #> [[2]] #> [1] "cap-shape=bell" "cap-shape=conical" #> [3] "cap-shape=convex" "cap-shape=flat" #> [5] "cap-shape=knobbed" "cap-shape=sunken" #> [7] "cap-surface=fibrous" "cap-surface=grooves" #> [9] "cap-surface=scaly" "cap-surface=smooth" #> [11] "cap-color=brown" "cap-color=buff" #> [13] "cap-color=cinnamon" "cap-color=gray" #> [15] "cap-color=green" "cap-color=pink" #> [17] "cap-color=purple" "cap-color=red" #> [19] "cap-color=white" "cap-color=yellow" #> [21] "bruises?=bruises" "bruises?=no" #> [23] "odor=almond" "odor=anise" #> [25] "odor=creosote" "odor=fishy" #> [27] "odor=foul" "odor=musty" #> [29] "odor=none" "odor=pungent" #> [31] "odor=spicy" "gill-attachment=attached" #> [33] "gill-attachment=descending" "gill-attachment=free" #> [35] "gill-attachment=notched" "gill-spacing=close" #> [37] "gill-spacing=crowded" "gill-spacing=distant" #> [39] "gill-size=broad" "gill-size=narrow" #> [41] "gill-color=black" "gill-color=brown" #> [43] "gill-color=buff" "gill-color=chocolate" #> [45] "gill-color=gray" "gill-color=green" #> [47] "gill-color=orange" "gill-color=pink" #> [49] "gill-color=purple" "gill-color=red" #> [51] "gill-color=white" "gill-color=yellow" #> [53] "stalk-shape=enlarging" "stalk-shape=tapering" #> [55] "stalk-root=bulbous" "stalk-root=club" #> [57] "stalk-root=cup" "stalk-root=equal" #> [59] "stalk-root=rhizomorphs" "stalk-root=rooted" #> [61] "stalk-root=missing" "stalk-surface-above-ring=fibrous" #> [63] "stalk-surface-above-ring=scaly" "stalk-surface-above-ring=silky" #> [65] "stalk-surface-above-ring=smooth" "stalk-surface-below-ring=fibrous" #> [67] "stalk-surface-below-ring=scaly" "stalk-surface-below-ring=silky" #> [69] "stalk-surface-below-ring=smooth" "stalk-color-above-ring=brown" #> [71] "stalk-color-above-ring=buff" "stalk-color-above-ring=cinnamon" #> [73] "stalk-color-above-ring=gray" "stalk-color-above-ring=orange" #> [75] "stalk-color-above-ring=pink" "stalk-color-above-ring=red" #> [77] "stalk-color-above-ring=white" "stalk-color-above-ring=yellow" #> [79] "stalk-color-below-ring=brown" "stalk-color-below-ring=buff" #> [81] "stalk-color-below-ring=cinnamon" "stalk-color-below-ring=gray" #> [83] "stalk-color-below-ring=orange" "stalk-color-below-ring=pink" #> [85] "stalk-color-below-ring=red" "stalk-color-below-ring=white" #> [87] "stalk-color-below-ring=yellow" "veil-type=partial" #> [89] "veil-type=universal" "veil-color=brown" #> [91] "veil-color=orange" "veil-color=white" #> [93] "veil-color=yellow" "ring-number=none" #> [95] "ring-number=one" "ring-number=two" #> [97] "ring-type=cobwebby" "ring-type=evanescent" #> [99] "ring-type=flaring" "ring-type=large" #> [101] "ring-type=none" "ring-type=pendant" #> [103] "ring-type=sheathing" "ring-type=zone" #> [105] "spore-print-color=black" "spore-print-color=brown" #> [107] "spore-print-color=buff" "spore-print-color=chocolate" #> [109] "spore-print-color=green" "spore-print-color=orange" #> [111] "spore-print-color=purple" "spore-print-color=white" #> [113] "spore-print-color=yellow" "population=abundant" #> [115] "population=clustered" "population=numerous" #> [117] "population=scattered" "population=several" #> [119] "population=solitary" "habitat=grasses" #> [121] "habitat=leaves" "habitat=meadows" #> [123] "habitat=paths" "habitat=urban" #> [125] "habitat=waste" "habitat=woods" #>colnames(dtrain)#> [1] "cap-shape=bell" "cap-shape=conical" #> [3] "cap-shape=convex" "cap-shape=flat" #> [5] "cap-shape=knobbed" "cap-shape=sunken" #> [7] "cap-surface=fibrous" "cap-surface=grooves" #> [9] "cap-surface=scaly" "cap-surface=smooth" #> [11] "cap-color=brown" "cap-color=buff" #> [13] "cap-color=cinnamon" "cap-color=gray" #> [15] "cap-color=green" "cap-color=pink" #> [17] "cap-color=purple" "cap-color=red" #> [19] "cap-color=white" "cap-color=yellow" #> [21] "bruises?=bruises" "bruises?=no" #> [23] "odor=almond" "odor=anise" #> [25] "odor=creosote" "odor=fishy" #> [27] "odor=foul" "odor=musty" #> [29] "odor=none" "odor=pungent" #> [31] "odor=spicy" "gill-attachment=attached" #> [33] "gill-attachment=descending" "gill-attachment=free" #> [35] "gill-attachment=notched" "gill-spacing=close" #> [37] "gill-spacing=crowded" "gill-spacing=distant" #> [39] "gill-size=broad" "gill-size=narrow" #> [41] "gill-color=black" "gill-color=brown" #> [43] "gill-color=buff" "gill-color=chocolate" #> [45] "gill-color=gray" "gill-color=green" #> [47] "gill-color=orange" "gill-color=pink" #> [49] "gill-color=purple" "gill-color=red" #> [51] "gill-color=white" "gill-color=yellow" #> [53] "stalk-shape=enlarging" "stalk-shape=tapering" #> [55] "stalk-root=bulbous" "stalk-root=club" #> [57] "stalk-root=cup" "stalk-root=equal" #> [59] "stalk-root=rhizomorphs" "stalk-root=rooted" #> [61] "stalk-root=missing" "stalk-surface-above-ring=fibrous" #> [63] "stalk-surface-above-ring=scaly" "stalk-surface-above-ring=silky" #> [65] "stalk-surface-above-ring=smooth" "stalk-surface-below-ring=fibrous" #> [67] "stalk-surface-below-ring=scaly" "stalk-surface-below-ring=silky" #> [69] "stalk-surface-below-ring=smooth" "stalk-color-above-ring=brown" #> [71] "stalk-color-above-ring=buff" "stalk-color-above-ring=cinnamon" #> [73] "stalk-color-above-ring=gray" "stalk-color-above-ring=orange" #> [75] "stalk-color-above-ring=pink" "stalk-color-above-ring=red" #> [77] "stalk-color-above-ring=white" "stalk-color-above-ring=yellow" #> [79] "stalk-color-below-ring=brown" "stalk-color-below-ring=buff" #> [81] "stalk-color-below-ring=cinnamon" "stalk-color-below-ring=gray" #> [83] "stalk-color-below-ring=orange" "stalk-color-below-ring=pink" #> [85] "stalk-color-below-ring=red" "stalk-color-below-ring=white" #> [87] "stalk-color-below-ring=yellow" "veil-type=partial" #> [89] "veil-type=universal" "veil-color=brown" #> [91] "veil-color=orange" "veil-color=white" #> [93] "veil-color=yellow" "ring-number=none" #> [95] "ring-number=one" "ring-number=two" #> [97] "ring-type=cobwebby" "ring-type=evanescent" #> [99] "ring-type=flaring" "ring-type=large" #> [101] "ring-type=none" "ring-type=pendant" #> [103] "ring-type=sheathing" "ring-type=zone" #> [105] "spore-print-color=black" "spore-print-color=brown" #> [107] "spore-print-color=buff" "spore-print-color=chocolate" #> [109] "spore-print-color=green" "spore-print-color=orange" #> [111] "spore-print-color=purple" "spore-print-color=white" #> [113] "spore-print-color=yellow" "population=abundant" #> [115] "population=clustered" "population=numerous" #> [117] "population=scattered" "population=several" #> [119] "population=solitary" "habitat=grasses" #> [121] "habitat=leaves" "habitat=meadows" #> [123] "habitat=paths" "habitat=urban" #> [125] "habitat=waste" "habitat=woods"#> xgb.DMatrix dim: 6513 x 126 info: label colnames: #> 'X1','X2','X3','X4','X5','X6','X7','X8','X9','X10','X11','X12','X13','X14','X15','X16','X17','X18','X19','X20','X21','X22','X23','X24','X25','X26','X27','X28','X29','X30','X31','X32','X33','X34','X35','X36','X37','X38','X39','X40','X41','X42','X43','X44','X45','X46','X47','X48','X49','X50','X51','X52','X53','X54','X55','X56','X57','X58','X59','X60','X61','X62','X63','X64','X65','X66','X67','X68','X69','X70','X71','X72','X73','X74','X75','X76','X77','X78','X79','X80','X81','X82','X83','X84','X85','X86','X87','X88','X89','X90','X91','X92','X93','X94','X95','X96','X97','X98','X99','X100','X101','X102','X103','X104','X105','X106','X107','X108','X109','X110','X111','X112','X113','X114','X115','X116','X117','X118','X119','X120','X121','X122','X123','X124','X125','X126'