dmlc / xgboost

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow
https://xgboost.readthedocs.io/en/stable/
Apache License 2.0
26.31k stars 8.73k forks source link

regarding predicted value from xgboost package in R #1656

Closed ghost closed 7 years ago

ghost commented 8 years ago

package using: ‘xgboost’ version 0.4-4

i am using model building function xgboost() using code :

fit <- xgboost(data =sparse_matrix , label = trainSet$OutputClass, max.depth = 4,eta = 1, nthread = 2, nround = 10, eval_metric = "merror",objective = "multi:softmax",num_class = 45)

when i use the prediction function:

Prediction<- predict(fit,sparse_matrixtestSet) the above code gave output as below( instead of class names its giving numerical equivalent value eventhough "label = trainSet$OutputClass" contain class names)

output: [1] 1 1 1 1 1 35 3 3 3 4 31 7 7 7 3 3 9 9 9 9 9 9 9 10 10 11 [27] 11 11 11 11 11 11 11 11 11 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 10 10 [53] 15 15 15 15 15 15 15 15 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 18 18 18 [79] 18 18 18 18 35 35 35 18 21 21 21 21 32 1 1 25 25 25 25 26 27 27 27 27 27 27 [105] 27 27 29 29 29 29 29 30 30 30 30 30 30 30 30 30 30 35 35 32 32 32 43 43 32 32 [131] 32 32 32 32 32 32 43 32 32 32 32 32 33

i have also set stringsAsFactors=FALSE while reading data set

`sessionInfo() R version 3.3.1 (2016-06-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

locale: [1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252
[3] LC_MONETARY=English_India.1252 LC_NUMERIC=C
[5] LC_TIME=English_India.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] Matrix_1.2-6 FSelectorRcpp_0.0.4 FSelector_0.21
[4] randomForest_4.6-12 caret_6.0-71 ggplot2_2.1.0
[7] lattice_0.20-33 SnowballC_0.5.1 qdap_2.2.5
[10] RColorBrewer_1.1-2 qdapTools_1.3.1 qdapRegex_0.6.0
[13] qdapDictionaries_1.0.6 tm_0.6-2 NLP_0.1-9

loaded via a namespace (and not attached): [1] Rcpp_0.12.7 RWeka_0.4-29 xlsxjars_0.6.1 gtools_3.5.0
[5] digest_0.6.10 assertthat_0.1 foreach_1.4.3 slam_0.1-38
[9] R6_2.1.3 plyr_1.8.4 chron_2.3-47 MatrixModels_0.4-1 [13] stats4_3.3.1 RWekajars_3.9.0-1 SparseM_1.72 minqa_1.2.4
[17] data.table_1.9.6 gdata_2.17.0 car_2.1-3 nloptr_1.0.4
[21] gender_0.5.1 splines_3.3.1 lme4_1.1-12 stringr_1.1.0
[25] igraph_1.0.1 RCurl_1.95-4.8 munsell_0.4.3 mgcv_1.8-12
[29] reports_0.1.4 nnet_7.3-12 tibble_1.2 gridExtra_2.2.1
[33] codetools_0.2-14 XML_3.98-1.4 dplyr_0.5.0 MASS_7.3-45
[37] bitops_1.0-6 openNLP_0.2-6 grid_3.3.1 nlme_3.1-128
[41] gtable_0.2.0 DBI_0.5-1 magrittr_1.5 scales_0.4.0
[45] xlsx_0.5.7 stringi_1.1.2 reshape2_1.4.1 openNLPdata_1.5.3-2 [49] venneuler_1.1-0 wordcloud_2.5 iterators_1.0.8 tools_3.3.1
[53] entropy_1.2.1 plotrix_3.6-3 parallel_3.3.1 pbkrtest_0.4-6
[57] colorspace_1.2-6 rJava_0.9-8 quantreg_5.29

` could some one please help, how to get prediction in term of class name instead of numerical equivalent value.

Thanks in advance....

pommedeterresautee commented 7 years ago

Old bug, no answer. Closing