Compare commits

...

2083 Commits
v0.32 ... v0.60

Author SHA1 Message Date
Tianqi Chen
4a8d63b6c8 Tag version 0.6 (#1422) 2016-07-29 11:23:06 -07:00
Vadim Khotilovich
75f401481f no exception throwing within omp parallel; set nthread in Learner (#1421) 2016-07-29 10:08:03 -07:00
Baltazar Bieniek
89c4f67f59 Class function returns more than one value (#1417)
Fix to a bug when the class function returns more than one value. In that case, the code will fail.
2016-07-29 10:07:09 -07:00
Fangzhou
a8adf16228 fix bug: doing rabit call after finalize in spark prediction phase (#1420) 2016-07-28 23:11:20 -05:00
Johnny Ho
328e8e4c69 Update rabit repository (#1409) 2016-07-27 11:40:42 -07:00
Vadim Khotilovich
d5c143367d [R-package] GPL2 dependency reduction and some fixes (#1401)
* [R] do not remove zero coefficients from gblinear dump

* [R] switch from stringr to stringi

* fix #1399

* [R] separate ggplot backend, add base r graphics, cleanup, more plots, tests

* add missing include in amalgamation - fixes building R package in linux

* add forgotten file

* [R] fix DESCRIPTION

* [R] fix travis check issue and some cleanup
2016-07-27 00:05:04 -07:00
Tianqi Chen
f6423056c0 Update dmlc-core (#1408) 2016-07-26 10:53:31 -07:00
Tianqi Chen
c3eb4f7000 Move model doc images to web-data (#1397) 2016-07-23 23:53:22 -07:00
Earthson Lu
d29edc677c fix #1377 spark-mllib scope: default => provided (#1381) 2016-07-20 23:10:49 -04:00
Shengwen Yang
7089301b62 Metrics for gamma regression (#1369)
* Add deviance metric for gamma regression

* Simplify the computation of nloglik for gamma regression

* Add a description for gamma-deviance

* Minor fix
2016-07-18 09:10:44 -05:00
Yuan (Terry) Tang
c60a356273 Remove pypi downloads badge (#1365) 2016-07-16 13:36:05 -04:00
anpark
0e61c514a7 fix duplicate loop over output_group when predict (#1342)
* fix sparse page source meta info empty when load from dmatrix

* fix duplicate loop over output_group when predict
2016-07-13 10:03:10 -07:00
convexquad
313764b3be Expose predictLeaf functionality in Scala XGBoostModel (#1351) 2016-07-12 06:55:24 -04:00
Titouan Lorieul
75d9be55de [py] fix label encoding of eval sets in sklearn API (#1244) 2016-07-11 05:29:46 -05:00
Yuan (Terry) Tang
197b4c6b18 Update DESCRIPTION (#1348) 2016-07-10 09:59:16 -07:00
Yuan (Terry) Tang
5f179340a8 Merge pull request #1347 from marugari/prototype_dart
add Dart tutorial
2016-07-10 09:19:44 -05:00
marugari
c332eb5a2b add Dart tutorial 2016-07-10 20:12:42 +09:00
Rahul
f14c160f4f [jvm-packages][xgboost4j-spark][Minor] Move sparkContext dependency from the XGBoostModel (#1335)
* Move sparkContext dependency from the XGBoostModel

* Update Spark example to declare SparkContext as implict
2016-07-08 06:43:33 -04:00
anpark
3f32b3f0eb fix sparse page source meta info empty when load from dmatrix (#1336) 2016-07-07 21:17:35 -07:00
Shengwen Yang
77d17f6264 Add support for Gamma regression (#1258)
* Add support for Gamma regression

* Use base_score to replace the lp_bias

* Remove the lp_bias config block

* Add a demo for running gamma regression in Python

* Typo fix

* Revise the description for objective

* Add a script to generate the autoclaims dataset
2016-07-06 10:22:46 -07:00
Ryan Curtin
f74e2439e0 Fix spelling error. (#1331) 2016-07-05 12:58:24 -07:00
JP Rosevear
13445e3522 Check for visual studio 12.0 and newer for c++11 support (#1330) 2016-07-04 18:32:20 -07:00
Vadim Khotilovich
11efa038bd [R-package] various fixes for R CMD check (#1328)
* [R] fix xgb.create.features

* [R] fixes for R CMD check
2016-07-04 10:40:35 -07:00
RAMitchell
f8d23b97be Add build instructions for Visual Studio 2013 (#1327) 2016-07-03 21:30:50 -07:00
Tong He
44ed6d5674 Merge pull request #1264 from khotilov/r_callbacks
[R-package] callbacks per #892
2016-07-03 13:43:29 -07:00
Vadim Khotilovich
4fb1b8a5a7 Merge branch 'master' into r_callbacks 2016-07-03 15:04:58 -05:00
Muhammad Haseeb Tariq
7533191af7 Typos in README (#1326)
* Inconsistency in libsvm formats

* note on libsvm formats

* typos in README

* Update README.md

* Update README.md

* Update README.md
2016-07-03 15:14:35 -04:00
Muhammad Haseeb Tariq
14f9697025 Inconsistency in libsvm formats (#1325)
* Inconsistency in libsvm formats

* note on libsvm formats
2016-07-03 10:49:41 -07:00
RAMitchell
93196eb811 cmake build system (#1314)
* Changed c api to compile under MSVC

* Include functional.h header for MSVC

* Add cmake build
2016-07-02 19:07:35 -07:00
Frank
3b73824842 Fix ambiguous call to abs(c or c++). (#1308) 2016-06-29 14:28:28 -07:00
Vadim Khotilovich
344d7b4699 [R] disable for now some of the RF tests that fail in travis 2016-06-27 02:49:23 -05:00
Vadim Khotilovich
ae0ca486ed added name to DESCRIPTION 2016-06-27 02:23:37 -05:00
Vadim Khotilovich
4b2eedc186 fix merge conflicts 2016-06-27 02:18:59 -05:00
Vadim Khotilovich
e1a52e896c [R] rm renamed CB's docs 2016-06-27 02:01:54 -05:00
Vadim Khotilovich
fd4300b95a [R] additional and modified tests 2016-06-27 02:00:46 -05:00
Vadim Khotilovich
3b6b344561 [R] adopt demos and vignettes to a more consistent parameter style 2016-06-27 02:00:39 -05:00
Vadim Khotilovich
a0aa305268 [R] docs update - callbacks and parameter style 2016-06-27 01:59:58 -05:00
Vadim Khotilovich
e9eb34fabc [R] parameter style consistency 2016-06-27 01:58:03 -05:00
Vadim Khotilovich
56bd442b31 [R] simplified the code; parameter style consistency 2016-06-27 01:57:57 -05:00
Vadim Khotilovich
8473b18c3d [R] consolidate importFrom-s; parameter style 2016-06-27 01:50:03 -05:00
Vadim Khotilovich
b9aeeda074 [R] in predict: doc, examples, reshape parameter 2016-06-27 01:49:57 -05:00
Vadim Khotilovich
c342614a81 [R] add parameter deprecation related utilities; code style 2016-06-27 01:49:51 -05:00
Vadim Khotilovich
76650c096f [R] CB naming change; cv-prediction as CB; add.cb function to ensure proper CB order; docs; minor fixes + changes 2016-06-27 01:49:47 -05:00
Nan Zhu
bd5b07873e [jvm-packages] create dmatrix with specified missing value (#1272)
* create dmatrix with specified missing value

* update dmlc-core

* support for predict method in spark package

repartitioning

work around

* add more elements to work around training set empty partition issue
2016-06-21 17:35:17 -04:00
Nan Zhu
c9a73fe2a9 explicitly throw exception when detecting empty partition in training dataset (#1281) 2016-06-15 16:03:37 -04:00
Bill Chambers
465e5dfb87 Broken Link in README (#1275) 2016-06-13 15:41:24 -07:00
Tong He
9cb872b879 Merge pull request #914 from catena/master
R: fix "bestInd" and add "best_ntreelimit" to xgb.Booster
2016-06-13 11:13:00 -07:00
catena
661c062bd9 add best_ntreelimit attribute 2016-06-13 12:45:20 +05:30
Vladimir
aaf0a73486 fixed error when eval False (#1271) 2016-06-12 09:36:36 -07:00
Yoshinori Nakano
7cfeb5f012 fix Dart::NormalizeTrees (#1265) 2016-06-09 15:28:24 -07:00
Vadim Khotilovich
4e1269b522 print.xgb.cv fix - Rd too 2016-06-09 10:12:20 -05:00
Vadim Khotilovich
79704cdfb4 print.xgb.cv fix 2016-06-09 09:29:19 -05:00
Vadim Khotilovich
f34f9fb9f7 R-callbacks tests + other tests brushup 2016-06-09 02:53:37 -05:00
Vadim Khotilovich
2e0ffcc303 R-callbacks docs 2016-06-09 02:52:09 -05:00
Vadim Khotilovich
422b0000a8 R-callbacks refactor 2016-06-09 02:46:13 -05:00
Vadim Khotilovich
754f3a6e07 protection against returning 0-length vector 2016-06-09 02:45:02 -05:00
Vadim Khotilovich
bdf14007b5 print method; construct from initial xgb.Booster 2016-06-09 02:43:25 -05:00
Vadim Khotilovich
264c222fe0 Merge remote-tracking branch 'upstream/master' 2016-06-09 02:32:26 -05:00
Yoshinori Nakano
949d1e3027 add Dart booster (#1220) 2016-06-08 14:04:01 -07:00
Shengwen Yang
e034fdf74c Fix issue #1236: cli_main crashes when dumping count:poisson model (#1253) 2016-06-07 21:52:47 -07:00
Szilard Pafka
e2c1aa8b51 link to talk (video+slides) by Tianqi at Los Angeles Data Science meetup (#1254)
* link to talk (video+slides) by Tianqi

* benchmark
2016-06-07 21:43:52 -07:00
Vadim Khotilovich
9a48a40cf1 Fixes for multiple and default metric (#1239)
* fix multiple evaluation metrics

* create DefaultEvalMetric only when really necessary

* py test for #1239

* make travis happy
2016-06-04 22:17:35 -07:00
Vadim Khotilovich
26a82621a2 make travis happy 2016-06-04 22:38:24 -05:00
Vadim Khotilovich
ba04a1d552 py test for #1239 2016-06-04 22:08:10 -05:00
Yuan (Terry) Tang
9ef86072f4 Merge pull request #1241 from KhaoticMind/master
[py]Preserve the actual objective used on the booster - Fixed #1215
2016-06-01 09:11:49 -05:00
Antonio Augusto Santos
19129b289c Preserve the actal objective used on the booster
Save the actual objective used on xgboost.train.

Not saving it was giving problem in predict_proba, as issue  #1215
2016-05-31 19:01:10 -03:00
Vadim Khotilovich
22ad94d281 create DefaultEvalMetric only when really necessary 2016-05-31 08:20:25 -05:00
Vadim Khotilovich
64b9dcf7b5 fix multiple evaluation metrics 2016-05-31 08:20:17 -05:00
Tianqi Chen
6e3463097d Merge pull request #1232 from zl1zl/master
fix cli_main crashes when using count:poisson regression
2016-05-27 20:22:50 -07:00
Zhongliang Li
1dde863c98 fix cli_main crashes when using count:poisson regression 2016-05-26 10:03:29 -07:00
Tianqi Chen
2ef81e0673 Merge pull request #1228 from albertotb/master
XGBModel doctstring
2016-05-25 10:38:48 -07:00
Alberto Torres
118eb2f1bb Merge pull request #1 from albertotb/sklearn-docstring
Update sklearn.py
2016-05-25 15:02:41 +02:00
Alberto Torres
af2e9ebd82 Update sklearn.py 2016-05-25 15:00:11 +02:00
Tianqi Chen
5c14daffe2 Merge pull request #1221 from ryaninhust/master
[DATA] fix instance weights loading
2016-05-24 20:19:31 -07:00
Nan Zhu
c6631ad2ed specify spark version (#1224) 2016-05-24 18:19:32 -04:00
yuanbowen
5898f1c59e [DATA] fix instance weights loading 2016-05-23 18:40:41 +08:00
Nan Zhu
c85b9012c6 [jvm-packages] xgboost4j-spark external memory (#1219)
* implement external memory support for XGBoost4J

* remove extra space

* enable external memory for prediction

* update doc
2016-05-22 14:01:28 -04:00
Tianqi Chen
587999755f Merge pull request #1218 from tqchen/master
[DATA] fix async data writing
2016-05-21 19:40:41 -07:00
tqchen
d816208797 [DATA] fix async data writing 2016-05-21 18:46:36 -07:00
Tianqi Chen
a4d8c1b49f redirects funding info to UW page 2016-05-21 11:07:55 -07:00
Tianqi Chen
cc5112d405 Merge pull request #1214 from tqchen/master
add style
2016-05-20 13:11:48 -07:00
tqchen
2c0c06639c add style 2016-05-20 13:11:27 -07:00
Tianqi Chen
47f359ca9f Merge pull request #1213 from tqchen/master
[DOC] refactor doc
2016-05-20 13:10:11 -07:00
tqchen
84ae514d7e [DOC] refactor doc 2016-05-20 13:09:42 -07:00
Tianqi Chen
e4ea166d05 Merge pull request #1211 from tqchen/master
[PYTHON] Refactor trainnig API to use callback
2016-05-19 21:47:25 -07:00
tqchen
149589c583 [PYTHON] Refactor trainnig API to use callback 2016-05-19 21:31:23 -07:00
Tianqi Chen
03996dd4e8 Update NEWS.md 2016-05-19 11:04:48 -07:00
Michaël Benesty
51154f42fe Merge pull request #1118 from khotilov/parsing_speedup
[R-package] xgb.model.dt.tree up to x100 faster
2016-05-17 17:48:11 +02:00
Vadim Khotilovich
611b317057 make travis happy 2016-05-17 00:24:06 -05:00
Vadim Khotilovich
2b8b18583f some more xgb.model.dt.tree improvements 2016-05-17 00:24:06 -05:00
Vadim Khotilovich
be65949ba2 xgb.model.dt.tree up to x100 faster 2016-05-17 00:24:06 -05:00
Tianqi Chen
49bbd72d08 Merge pull request #1198 from khotilov/xgb_attributes
More functionality for model attributes
2016-05-16 09:31:58 -07:00
Vadim Khotilovich
ffed95eec0 py: replace attr_names() with attributes() 2016-05-15 22:04:38 -05:00
Vadim Khotilovich
26b36714ea doxygen suggested fix 2016-05-15 03:05:19 -05:00
Vadim Khotilovich
185fef3fce fixes for lint 2016-05-15 02:35:37 -05:00
Vadim Khotilovich
a13a3a4d76 attr_names for python interface; attribute deletion via set_attr 2016-05-15 02:05:10 -05:00
Vadim Khotilovich
8664217a5a [R] more attribute handling functionality 2016-05-14 18:19:18 -05:00
Vadim Khotilovich
ea9285dd4f methods to delete an attribute and get names of available attributes 2016-05-14 18:19:18 -05:00
Tianqi Chen
9c26566eb0 Merge pull request #1190 from geneorama/geneorama-patch-1
add `scale_pos_weight` to parameter documentation
2016-05-11 15:06:21 -07:00
Tianqi Chen
07003e8342 Merge pull request #1191 from SeanBE/fix-build-doc
make grammar and spelling fixes to build doc
2016-05-11 15:06:04 -07:00
Sean Löfgren
bf322322fe make grammar and spelling fixes to build doc 2016-05-11 22:56:29 +01:00
Gene Leynes
2e7abffffb add scale_pos_weight to parameter documentation 2016-05-11 14:10:36 -05:00
Tianqi Chen
617aeb912b Merge pull request #1186 from tqchen/master
Update rabit to latest
2016-05-10 20:18:14 -07:00
tqchen
44d4a62631 Update rabit to latest 2016-05-10 20:07:22 -07:00
Tianqi Chen
bab69919d2 Merge pull request #1181 from shaynekang/visible_deprecation_warning
Fix VisibleDeprecationWarning
2016-05-07 11:11:58 -07:00
Shayne Kang
bf24d6ae98 fix VisibleDeprecationWarning 2016-05-08 01:44:04 +09:00
Yuan (Terry) Tang
840481d215 Merge pull request #1180 from borundev/master
call to DMatrix was missing 'missing=self.missing'
2016-05-07 10:42:00 -04:00
Borun Dev Chowdhury
fc02f8a2dc cosmetic change
cosmetic change of putting space after comma compared to previous edit.
2016-05-07 12:33:37 +02:00
borundev
95bcff90af XGBModel.fit had a call to DMatrix without missing=self.missing. fixed that 2016-05-07 12:32:03 +02:00
Tianqi Chen
6e79ba831a Merge pull request #1166 from khotilov/r_api_fix
[R-package] C-API fix; attribute accessors
2016-05-06 20:35:28 -07:00
Yuan (Terry) Tang
b92e2252b0 Merge pull request #1173 from tlorieul/sklearn_get_trees_leaves
[py] added apply function in sklearn API to return the predicted leaves
2016-05-04 08:02:08 -05:00
Titouan Lorieul
3ab8f0b13d [py] added apply function in sklearn API to return the predicted leaves 2016-05-04 12:27:30 +02:00
Saiwing Yeung
28cdc10259 Fixed a typo (#1172)
panda -> Pandas
2016-05-03 19:29:22 -05:00
Alistair Johnson
6750c8b743 Added other feature importances in python package (#1135)
* added new function to calculate other feature importances

* added capability to plot other feature importance measures

* changed plotting default to fscore

* added info on importance_type to boilerplate comment

* updated text of error statement

* added self module name to fix call

* added unit test for feature importances

* style fixes
2016-05-02 12:25:24 -05:00
Vadim Khotilovich
5a78118396 use short-circuiting scalar && 2016-05-02 01:01:22 -05:00
Vadim Khotilovich
79c7c9e5bb R accessors for model attributes 2016-05-02 00:20:44 -05:00
Vadim Khotilovich
0839aed380 fix attribute accessors C-interface for R 2016-05-02 00:19:38 -05:00
Yuan (Terry) Tang
c2c61eefd9 Merge pull request #1164 from sinhrks/fix_doc
DOC/TST: Fix Python sklearn dep
2016-05-01 16:18:03 -05:00
Vadim Khotilovich
b5fb437aa7 learner attribute setter & getter for R interface 2016-05-01 15:40:51 -05:00
Vadim Khotilovich
b588479f66 .Call-interface functions need to return SEXP 2016-05-01 15:40:51 -05:00
sinhrks
9da2f3e613 DOC/TST: Fix Python sklearn dep 2016-05-01 17:27:43 +09:00
Tianqi Chen
2f2ad21de4 Merge pull request #1153 from khotilov/seed_in_configure
Fixes for repeated Configure calls
2016-04-30 10:43:14 -07:00
Yuan (Terry) Tang
da85a4e923 Merge pull request #1161 from Far0n/eta_decay_fix
[py] eta decay bugfix
2016-04-30 10:50:52 -04:00
Faron
ad3f49e881 [py] eta decay bugfix 2016-04-30 15:51:57 +02:00
Yuan (Terry) Tang
9bc2ac4bd0 Merge pull request #1158 from sinhrks/feature_bug
Bug mixing DMatrix's with and without feature names
2016-04-30 09:20:58 -04:00
sinhrks
6bab164d80 Bug mixing DMatrix's with and without feature names 2016-04-30 14:42:57 +09:00
Yuan (Terry) Tang
ff4dda2102 Merge pull request #1159 from saiwing-yeung/my-fix
fixed typo
2016-04-30 00:38:18 -04:00
Saiwing Yeung
a6909e389f fixed typo
panda -> Pandas
2016-04-30 09:24:39 +08:00
Yuan (Terry) Tang
3434083d3e Merge pull request #1017 from Far0n/hist
[py] split value histograms
2016-04-28 13:52:49 -05:00
Faron
cf607e2448 [py] split value histograms 2016-04-28 20:26:21 +02:00
Yuan (Terry) Tang
6691d5c3f4 Merge pull request #1141 from sinhrks/pandas_features
BUG: XGBClassifier.feature_importances_ raises ValueError if input is…
2016-04-27 18:07:51 -05:00
sinhrks
c55cc809e5 BUG: XGBClassifier.feature_importances_ raises ValueError if input is pandas DataFrame 2016-04-27 21:50:03 +09:00
Vadim Khotilovich
24e3c5773e Merge branch 'master' into seed_in_configure 2016-04-26 22:47:01 -05:00
Vadim Khotilovich
811c6ef58b obey the lint 2016-04-26 22:11:19 -05:00
Tianqi Chen
4149854633 Merge pull request #1068 from Laurae2/master
Updated obsolete installation instructions
2016-04-26 19:50:06 -07:00
Tianqi Chen
43c073d8c5 Merge pull request #1142 from sinhrks/flake8
Enable flake8 for Python
2016-04-26 19:47:42 -07:00
Tianqi Chen
5d7a69663b Merge pull request #1145 from khotilov/error_at_threshold
ability to specify threshold for the error metric
2016-04-26 19:46:37 -07:00
Vadim Khotilovich
3e0732dea9 in Configure, set random seed only for uninitialized model 2016-04-26 02:03:22 -05:00
Vadim Khotilovich
0527b17c9d avoid collecting duplicate parameters in Booster::cfg_ 2016-04-25 22:08:53 -05:00
Vadim Khotilovich
1160d0bf25 ability to specify threshold for the error metric 2016-04-25 01:29:04 -05:00
sinhrks
8fc2456c87 Enable flake8 2016-04-24 17:32:31 +09:00
Tianqi Chen
b3c9e6a0db Merge pull request #1139 from hxd1011/patch-2
Update parameter.md
2016-04-22 12:12:01 -07:00
hxd1011
04ace6311b Update parameter.md
add some detail how the parameter will affect model complexity, and comment on the base score.
2016-04-22 14:42:11 -04:00
Nan Zhu
060350f64c Merge pull request #1103 from dmlc/revert-1100-master
Revert "updating JVM docs"
2016-04-11 22:36:37 -04:00
Nan Zhu
e6de01baaf Revert "updating JVM docs" 2016-04-11 22:00:45 -04:00
Tianqi Chen
f2557ce530 Merge pull request #1102 from tqchen/master
allow common python output in single node
2016-04-11 16:04:52 -07:00
Tianqi Chen
db4c5bc627 Merge pull request #1100 from avloss/master
updating JVM docs
2016-04-11 15:49:33 -07:00
tqchen
49f3892942 allow common python output in single node 2016-04-11 15:48:16 -07:00
avl055
f75d78f686 updating JVM docs
adding “-DskipTests” to Docs for JVM. without this flag building takes
forever
2016-04-10 23:52:09 +01:00
Yuan (Terry) Tang
59610c49df Merge pull request #1098 from zyxue/patch-1
improved docstring for folds in cv function
2016-04-09 14:09:10 -04:00
zyxue
79b35da308 improved docstring for folds in cv function 2016-04-09 10:21:56 -07:00
Yuan (Terry) Tang
c791894668 Merge pull request #1097 from Far0n/patch-1
winning solution
2016-04-09 07:44:43 -04:00
Far0n
d7e5095e7c Update README.md
Winning solution added: "Homesite Quote Conversion" (@Kaggle)
2016-04-09 09:12:49 +02:00
Tong He
4af55518f2 Merge pull request #1050 from khotilov/S4toS3
[R-package] Convert to S3; some new DMatrix methods
2016-04-03 11:52:08 -07:00
Vadim Khotilovich
25965227b3 Merge branch 'master' into S4toS3 2016-04-02 14:30:44 -05:00
Tianqi Chen
714901eac5 Merge pull request #1071 from khotilov/make_fix
fix Makefile to use MAKE variable
2016-03-30 23:22:21 -07:00
Vadim Khotilovich
de63993543 Merge branch 'master' into make_fix 2016-03-31 01:19:52 -05:00
Vadim Khotilovich
9f177d7353 fix Makefile to use MAKE variable 2016-03-31 00:47:51 -05:00
Tianqi Chen
babf1d7840 Merge pull request #1048 from WojciechMigda/xgboostercreate-api-fix
XGBoosterCreate api unified to use const DMatrixHandle[] argument
2016-03-30 20:56:10 -07:00
Laurae2
77136baf2c Updated obsolete installation instructions
Fixed local compilation, and installation for R package and Python
package. Modified the according documents.
2016-03-30 17:43:54 +02:00
WojciechMigda
30a306b974 Merge branch 'master' into xgboostercreate-api-fix 2016-03-30 11:25:21 +02:00
Nan Zhu
6eda06256e Merge pull request #1057 from CodingCat/master
update doc
2016-03-28 20:09:53 -04:00
Nan Zhu
e27977d416 Merge branch 'master' into master 2016-03-28 19:03:04 -04:00
CodingCat
daeee84e4d update doc 2016-03-28 19:02:37 -04:00
Vadim Khotilovich
33131e2e13 make travis happy 2016-03-27 20:28:40 -05:00
Vadim Khotilovich
fb5291271e fix print.xgb.DMatrix doc 2016-03-27 19:42:26 -05:00
Vadim Khotilovich
4b760762f9 added unit tests for xgb.DMatrix 2016-03-27 19:23:08 -05:00
Vadim Khotilovich
71f402ac16 convert S4 to S3; add some extra methods to DMatrix 2016-03-27 19:22:22 -05:00
Vadim Khotilovich
d27bfb61b0 consolidated DMatrix&Booster stuff into xgb.DMatrix.R & xgb.Booster.R 2016-03-27 19:17:13 -05:00
Vadim Khotilovich
1d504d6c6c added XGDMatrixNumCol_R function 2016-03-27 19:11:22 -05:00
Wojciech Migda
6a5eb47789 XGBoosterCreate api unified to use const DMatrix[] argument 2016-03-26 19:42:58 +01:00
Nan Zhu
605c23e0dc Merge pull request #1037 from CodingCat/allow_empty_partitions
[jvm-packages] allow empty partitions
2016-03-23 15:04:51 -04:00
Nan Zhu
dfafce4cfd Merge branch 'master' into allow_empty_partitions 2016-03-23 12:30:33 -04:00
CodingCat
d8535313eb allow empty partitions 2016-03-23 12:30:06 -04:00
Tianqi Chen
03dfffca15 Merge pull request #1028 from kilojoules/patch-6
More verbose error message: which fields have impropper data types
2016-03-22 21:02:17 -07:00
Julian Quick
bbb9ce1641 Verbose message: which fields have impropper data types
A more verbose error message letting the user know which fields have impropper data types
2016-03-22 14:13:29 -06:00
Tianqi Chen
1625dab1cb Merge pull request #1025 from andyandy1992/master
Fixed typos.
2016-03-22 08:49:32 -07:00
Andrew Smith
5efc1ee3a4 Fixed typos. 2016-03-22 12:54:18 +00:00
Nan Zhu
c135703655 Merge pull request #1012 from CodingCat/master
update installation doc
2016-03-19 08:58:41 -04:00
Nan Zhu
8842176888 Merge branch 'master' into master 2016-03-19 08:16:18 -04:00
CodingCat
f1114688a7 update installation doc 2016-03-19 08:15:56 -04:00
Tianqi Chen
7c555d5bc6 Update README.md 2016-03-18 15:28:38 -07:00
Nan Zhu
11415f228f Merge pull request #1010 from CodingCat/master
[jvm-packages] adjust numWorkers for test
2016-03-18 11:30:31 -04:00
Nan Zhu
14a031a1ab Merge branch 'master' into master 2016-03-18 10:36:20 -04:00
CodingCat
55ab1c6a22 adjust numWorkers for test 2016-03-18 10:34:36 -04:00
Nan Zhu
a2146708bd Merge pull request #1008 from CodingCat/master
typo fix
2016-03-18 07:12:14 -04:00
Nan Zhu
0b998d5249 Merge branch 'master' into master 2016-03-18 06:56:06 -04:00
Tianqi Chen
0e0f0e75f6 Merge pull request #1009 from Keiku/work
Add a new winning solution to demo/README.md
2016-03-17 20:33:04 -07:00
Keiku
7016bee98f Add a new winning solution to demo/README.md 2016-03-18 12:06:36 +09:00
Nan Zhu
ffe7af572c Merge branch 'master' into master 2016-03-17 23:00:50 -04:00
Tianqi Chen
375a8a97a6 Merge pull request #1006 from kilojoules/patch-4
a more verbose field mismatch error message
2016-03-17 19:56:33 -07:00
CodingCat
cc0722a4aa typo fix 2016-03-17 22:17:08 -04:00
Julian Quick
2cd109fb98 a more verbose field mismatch error message
This error message can be hard to understand when there are several fields, as shown in the example below. This improves the error message, letting the user know which fields were unexpected or missing.

    import xgboost as xgb
    import pandas as pd
    train = pd.DataFrame({'a':[1], 'b':[2], 'c':[3], 'd':[4], 'f':[2], 'g':2, 'etc etc etc':[11]})
    dtrain = xgb.DMatrix(train.drop('d', axis=1), train.d)
    test = pd.DataFrame({'a':[1], 'b':[2], 'c':[1], 'd':[4], 'e':[2], 'f':[2], 'g':2, 'etc etc etc':[11]})
    dtest = xgb.DMatrix(test)
    modl = xgb.train({}, dtrain)
    modl.predict(dtest)
    
    
    # ValueError: feature_names mismatch: [u'a', u'b', u'c', u'etc etc etc', u'f', u'g'] [u'a', u'b', u'c', u'd', u'e', u'etc etc etc', u'f', u'g']
2016-03-17 18:13:30 -06:00
Tianqi Chen
c449dc6874 Merge pull request #1003 from DrAndrey/master
change type of xgbclassifier.classes_ from list to numpy array
2016-03-17 09:51:05 -07:00
DAndrey
311f7c8f47 change type of xgbclassifier.classes_ from list to numpy array 2016-03-17 16:54:33 +03:00
Tianqi Chen
612ccd0bb7 Merge pull request #1000 from CodingCat/installation_doc
[jvm-packages] run native lib building command from maven
2016-03-16 14:06:19 -07:00
CodingCat
6f273a8c21 update docs 2016-03-16 17:00:44 -04:00
CodingCat
a31a978471 run native lib building command from maven 2016-03-16 16:47:08 -04:00
Tianqi Chen
6321bc20ea Merge pull request #996 from CNevd/patch-1
Update README.md
2016-03-15 19:34:36 -07:00
CNevd
73d5965961 Update README.md 2016-03-16 10:28:22 +08:00
Tianqi Chen
c2fa67757a Merge pull request #995 from ohld/year-update
update year in LICENSE, conf.py and README.md files
2016-03-15 09:34:10 -07:00
Okhlopkov Daniil Olegovich
5829eb3cf2 update year in LICENSE, conf.py and README.md files
I found that year in files is not up-to-date
2016-03-15 16:51:34 +03:00
Tianqi Chen
9a5489ee15 Merge pull request #992 from tqchen/master
[FLINK] remove nWorker from API
2016-03-14 16:29:58 -07:00
tqchen
90f7220736 [FLINK] remove nWorker from API 2016-03-14 16:18:35 -07:00
Tianqi Chen
084ed6224d Update README.md 2016-03-14 15:21:39 -07:00
Tianqi Chen
29ad3ab2c3 Merge pull request #991 from CodingCat/master
xgboost4j intro
2016-03-14 14:07:11 -07:00
CodingCat
d1c5280f4b xgboost4j intro 2016-03-14 16:44:03 -04:00
Nan Zhu
00caf2c956 Merge pull request #988 from CodingCat/master
[jvm-packages] getter of XGBoostModel
2016-03-14 07:54:03 -04:00
CodingCat
c3e56017cc Merge branch 'master' of https://github.com/dmlc/xgboost 2016-03-14 07:27:53 -04:00
CodingCat
3a951d0ab8 getter of XGBoostModel 2016-03-14 07:26:51 -04:00
Nan Zhu
362eb4bd02 Merge pull request #983 from CodingCat/master
[jvm-packages] upgrade spark version to 1.6.1
2016-03-13 23:04:16 -04:00
Nan Zhu
e3fa7753f5 Merge branch 'master' into master 2016-03-13 22:46:38 -04:00
CodingCat
6f92f1c117 update spark version to 1.6.1 2016-03-13 22:46:06 -04:00
Tianqi Chen
e1b2ad2e5e Merge pull request #980 from tqchen/master
[METHOD], add tree method option to prefer faster algo
2016-03-13 12:25:03 -07:00
tqchen
a2714fe052 [METHOD], add tree method option to prefer faster algo 2016-03-13 12:24:47 -07:00
Tianqi Chen
4454c7b72a Update README.md 2016-03-13 12:13:41 -07:00
Tianqi Chen
5fb09dc0ab Merge pull request #979 from CodingCat/kryo
[jvm-packages] support kryo serialization
2016-03-13 11:25:01 -07:00
Tianqi Chen
05b692590d Merge pull request #978 from CodingCat/worker_num
[jvm-packages] jvm doc index
2016-03-13 11:24:33 -07:00
Nan Zhu
a382c1698a Merge branch 'master' into worker_num 2016-03-13 11:57:28 -04:00
Nan Zhu
cc1e608a3d Merge branch 'master' into kryo 2016-03-13 11:57:17 -04:00
CodingCat
f2ef958ebb support kryo serialization 2016-03-13 11:55:14 -04:00
CodingCat
9011acf52b jvm doc index 2016-03-13 09:20:51 -04:00
Nan Zhu
3ce33563f2 Merge pull request #975 from CodingCat/worker_num
force the user to set number of workers
2016-03-12 13:47:27 -05:00
CodingCat
16b9e92328 force the user to set number of workers 2016-03-12 13:33:57 -05:00
Nan Zhu
980898f3fb Merge pull request #971 from CodingCat/set_nthread
set nthread to spark.task.cpus by default
2016-03-11 20:19:56 -05:00
CodingCat
5f441a29a8 set nthread to spark.task.cpus by default 2016-03-11 20:07:09 -05:00
Tianqi Chen
cbabaeba0c Merge pull request #969 from tqchen/master
JVM API Update
2016-03-11 12:36:27 -08:00
Tianqi Chen
57987100bc Merge pull request #3 from CodingCat/fix_examples
adjust the API signature as well as the docs
2016-03-11 12:29:33 -08:00
CodingCat
a3b2e76230 update README for jvm-packages 2016-03-11 15:28:55 -05:00
CodingCat
400b1faecc adjust the API signature as well as the docs 2016-03-11 15:22:44 -05:00
CodingCat
97e4dcde98 Merge branch 'master' of https://github.com/tqchen/xgboost into fix_examples 2016-03-11 15:13:54 -05:00
tqchen
2a6ac6fd34 Update JVM Doc 2016-03-11 11:53:24 -08:00
tqchen
79f2d0cf70 Update JVM Doc 2016-03-11 11:50:21 -08:00
Tianqi Chen
2dac506773 Merge pull request #968 from CodingCat/master
XGBoost4J intro
2016-03-11 10:59:42 -08:00
Nan Zhu
61db5aa575 Merge branch 'master' into master 2016-03-11 13:58:24 -05:00
CodingCat
6b9442a7f8 XGBoost4J intro 2016-03-11 13:58:00 -05:00
CodingCat
ab68a0ccc7 fix examples 2016-03-11 13:57:03 -05:00
Nan Zhu
acdd23e789 Merge pull request #967 from CodingCat/master
[jvm-packages] change the API name
2016-03-11 10:59:16 -05:00
CodingCat
aca0096b33 more updates for Flink
more fix
2016-03-11 10:15:49 -05:00
CodingCat
43d7a85bc9 change the API name since we support not only HDFS and local file system 2016-03-11 10:05:32 -05:00
Nan Zhu
8e3ce908fe Merge pull request #965 from shaform/fs
Support the cases when user load dataset and save model to two different file systems
2016-03-11 09:25:02 -05:00
Shaform
6558ef3273 support different types of filesystems 2016-03-11 22:06:40 +08:00
Nan Zhu
00e7e4eef0 Merge pull request #964 from CodingCat/master
fix create_jni.sh
2016-03-11 09:00:20 -05:00
CodingCat
51b0e7010c fix create_jni sh 2016-03-11 08:46:44 -05:00
Tianqi Chen
39359edbd8 Merge pull request #962 from tqchen/master
Fix continue training in CLI
2016-03-10 22:11:45 -08:00
Tianqi Chen
04f7fe9c36 Merge pull request #961 from tqchen/master
Fix multi-class loading
2016-03-10 19:39:28 -08:00
tqchen
59d59a968d Fix continue training in CLI 2016-03-10 19:39:09 -08:00
tqchen
ec2fb5bc48 Fix multi-class loading 2016-03-10 19:22:26 -08:00
Tianqi Chen
d02bd41623 Merge pull request #959 from tqchen/master
Fix continue training in CLI
2016-03-10 18:12:54 -08:00
tqchen
96b17971ac Fix continue training in CLI 2016-03-10 12:43:25 -08:00
Tianqi Chen
845f80ec22 Merge pull request #958 from tqchen/master
fix link
2016-03-10 12:28:46 -08:00
tqchen
d35cab6911 fix link 2016-03-10 12:28:29 -08:00
Tianqi Chen
5b3ece2ca9 Merge pull request #957 from tqchen/master
Add Reference
2016-03-10 12:27:41 -08:00
tqchen
f3e2878784 Add Reference 2016-03-10 12:26:01 -08:00
Tianqi Chen
7b2e128c91 Merge pull request #951 from tcfuji/master
Add tpot to Tools using XGBoost
2016-03-10 07:53:29 -08:00
Tianqi Chen
d913cbbfbc Merge pull request #954 from CodingCat/worker_num
[jvm-packages] allow the user to specify the worker number and avoid unnecessary shuffle
2016-03-10 07:53:20 -08:00
CodingCat
d47df5c1d8 allow the user to specify the worker number and avoid unnecessary shuffle 2016-03-10 06:58:30 -05:00
CodingCat
e0a3f1c000 nthread no larger than spark.task.cpus 2016-03-10 05:51:07 -05:00
Ted Fujimoto
13486cf672 Add tpot to Tools using XGBoost 2016-03-09 23:27:34 -08:00
Tianqi Chen
bbe2b2f0b6 Merge pull request #949 from CodingCat/scala_examples
fix typo in README
2016-03-09 16:00:27 -08:00
Nan Zhu
e0555d2ddc Merge branch 'master' into scala_examples 2016-03-09 17:23:22 -05:00
CodingCat
4e86c8c866 fix typo in README 2016-03-09 17:22:19 -05:00
Tianqi Chen
db7a4e2ada Merge pull request #944 from CodingCat/scala_examples
Scala examples
2016-03-09 10:08:07 -08:00
CodingCat
7e30ada8c1 update README 2016-03-09 13:05:08 -05:00
Nan Zhu
b398c145a9 Merge branch 'master' into scala_examples 2016-03-09 12:57:41 -05:00
Tianqi Chen
a23e091be1 Merge pull request #946 from saiias/modify_makefile
modify Makefile
2016-03-09 09:52:22 -08:00
CodingCat
005b1276d0 remove duplicate in stream close 2016-03-09 12:33:49 -05:00
CodingCat
852c5a4b32 code formatting in XGBoostModel 2016-03-09 12:31:35 -05:00
CodingCat
c9830cd8b1 remove spark/flink examples 2016-03-09 12:31:35 -05:00
CodingCat
8cfa752fa0 add scala examples 2016-03-09 12:31:35 -05:00
Tianqi Chen
f64516c8d0 Merge pull request #942 from CodingCat/revise_java
refactor jvm API
2016-03-09 09:30:12 -08:00
saiias
357c89fa93 modify Makefile 2016-03-09 23:11:48 +09:00
CodingCat
a08cc8aad4 allow the user define how many workers they need 2016-03-08 18:46:53 -05:00
CodingCat
909c6af330 add test resources manually 2016-03-08 18:43:30 -05:00
CodingCat
fa03aaeb63 revise current API 2016-03-08 17:18:55 -05:00
Tianqi Chen
9911771b02 Merge pull request #939 from tqchen/master
update dmlc-core
2016-03-08 08:02:02 -08:00
tqchen
7aafd8f777 update dmlc-core 2016-03-08 08:01:47 -08:00
Tianqi Chen
8a12a78427 Merge pull request #936 from tqchen/master
Fix broken tracker
2016-03-07 21:00:39 -08:00
tqchen
7cbb9da0e6 Fix broken tracker 2016-03-07 21:00:20 -08:00
Tianqi Chen
6f5632dd6e Merge pull request #934 from tqchen/master
[Spark] Refactor train, predict, add save
2016-03-06 21:57:38 -08:00
tqchen
435a0425b9 [Spark] Refactor train, predict, add save 2016-03-06 21:51:08 -08:00
Tianqi Chen
3402953633 Update README.md 2016-03-06 21:15:43 -08:00
Tianqi Chen
0fd433ff0f Update README.md 2016-03-06 21:15:32 -08:00
Tianqi Chen
d4161bdeec Merge pull request #932 from tqchen/master
Add doc badge
2016-03-06 21:09:32 -08:00
tqchen
dda226ab85 Add doc badge 2016-03-06 21:09:13 -08:00
Tianqi Chen
3d8f2fb1b9 Merge pull request #931 from tqchen/master
Add JVM Package
2016-03-06 21:05:35 -08:00
tqchen
8cc8f227c3 Add JVM Package 2016-03-06 21:05:17 -08:00
Tianqi Chen
8c6cbe7608 Merge pull request #930 from tqchen/master
Fix rabit
2016-03-06 20:54:49 -08:00
tqchen
bec7332eea Fix rabit 2016-03-06 20:54:27 -08:00
Tianqi Chen
54f13ab9e7 Merge pull request #929 from tqchen/master
[DOC-JVM] Refactor JVM docs
2016-03-06 20:52:40 -08:00
tqchen
c05c5bc7bc [DOC-JVM] Refactor JVM docs 2016-03-06 20:42:01 -08:00
Tianqi Chen
79f9fceb6b Merge pull request #927 from CodingCat/spark_example
Spark example
2016-03-06 15:46:54 -08:00
CodingCat
c211a80633 log tracker exit value in logger
capture InterruptedException
2016-03-06 17:37:18 -05:00
CodingCat
718a9d8c96 use another thread to control spark job 2016-03-06 15:46:27 -05:00
CodingCat
6499422e90 fix the merge 2016-03-06 15:22:05 -05:00
CodingCat
16008ebfb8 merge with master 2016-03-06 15:16:55 -05:00
CodingCat
50337d1906 fix rabitEnv 2016-03-06 14:56:49 -05:00
Tianqi Chen
cf2a7851eb Merge pull request #926 from tqchen/master
[JVM] Refactor, add filesys API
2016-03-06 11:49:01 -08:00
CodingCat
808e30f9fc example of DistTrainWithSpark and trigger job with foreachPartition 2016-03-06 14:34:23 -05:00
tqchen
56f7a414d1 [JVM] Refactor, add filesys API 2016-03-06 11:33:48 -08:00
CodingCat
f768edfede adjust the return values of RabitTracker.waitFor(), remove typesafe.Config 2016-03-06 08:44:04 -05:00
Tianqi Chen
457ff82e33 Merge pull request #919 from Far0n/master
Complete Guide to Parameter Tuning in XGBoost
2016-03-05 20:18:48 -08:00
Tianqi Chen
300c16d0f6 Merge pull request #923 from tqchen/master
[FLINK] Make runnable flink
2016-03-05 18:04:54 -08:00
tqchen
99dc311f6d [FLINK] Make runnable flink 2016-03-05 17:59:22 -08:00
Tianqi Chen
3ddddfce79 Merge pull request #922 from CodingCat/label
spark with new labeledpoint
2016-03-05 17:04:32 -08:00
CodingCat
130ca7b00c test case for XGBoostSpark 2016-03-05 19:41:26 -05:00
CodingCat
f0647ec76d test resources 2016-03-05 18:18:07 -05:00
CodingCat
5c1af13f84 distributed in RDD 2016-03-05 17:50:40 -05:00
CodingCat
fb41e4e673 spark with new labeledpoint
fix import order
2016-03-05 17:22:34 -05:00
Tianqi Chen
74bda4bfc5 Merge pull request #921 from tqchen/master
[JVM] Add LabeledPoint read support
2016-03-05 14:18:20 -08:00
tqchen
514df14baf [JVM] Add LabeledPoint read support
fix
2016-03-05 13:36:33 -08:00
Far0n
3a34c53f57 Complete Guide to Parameter Tuning in XGBoost 2016-03-05 21:51:47 +01:00
Tianqi Chen
ae032b12b4 Merge pull request #918 from tqchen/master
Add Labeled Point, minor fix build
2016-03-05 12:21:22 -08:00
tqchen
ac8e950227 Add Labeled Point, minor fix build 2016-03-05 12:12:43 -08:00
Tianqi Chen
51d8595372 Merge pull request #911 from CodingCat/spark_xgboost
[WIP]xgboost4j-spark
2016-03-05 11:49:24 -08:00
CodingCat
bb43177eb1 merge 2016-03-05 14:40:30 -05:00
tqchen
e8560c7909 [refactor] move java package to namespace java 2016-03-05 14:04:13 -05:00
tqchen
ae969a0e69 [refactor] move java package to namespace java 2016-03-05 14:00:04 -05:00
tqchen
81dbf564a4 [Flink] Check 2016-03-05 13:57:26 -05:00
CodingCat
2cec10c46f try to get more memory from Travis 2016-03-05 08:44:56 -05:00
CodingCat
b2d705ffb0 framework of xgboost-spark
iterator

return java iterator and recover test
2016-03-05 08:44:55 -05:00
CodingCat
1540773340 sketch of xgboost-spark
chooseBestBooster shall be in Boosters

remove tracker.py

rename XGBoost

remove cross-validation
2016-03-05 08:44:55 -05:00
Tianqi Chen
4568692daf Merge pull request #913 from tqchen/master
update libsvm file to start with 1 index
2016-03-05 00:02:47 -08:00
tqchen
a894ab6898 update libsvm file to start with 1 index 2016-03-05 00:01:42 -08:00
Tianqi Chen
e23a24be8c Merge pull request #912 from tqchen/master
[JVM] Add Iterator loading API
2016-03-04 18:14:30 -08:00
tqchen
86871d4be9 [JVM] Add Iterator loading API 2016-03-04 17:37:46 -08:00
Tianqi Chen
770b3451ca Merge pull request #907 from tqchen/master
[DIST] Enable multiple thread  make rabit and xgboost threadsafe
2016-03-04 08:24:00 -08:00
Tianqi Chen
04bdbca63f Merge pull request #2 from CodingCat/tianqi
revise the RabitTracker Impl & delete FileUtil class
2016-03-04 08:02:58 -08:00
CodingCat
416e1434e7 change initTracker() to static 2016-03-04 10:55:02 -05:00
CodingCat
10a1517502 revise the RabitTracker Impl
delete FileUtil class

fix bugs
2016-03-04 10:08:37 -05:00
tqchen
0df2ed80c8 [JVM] Make JVM Serializable 2016-03-03 21:04:02 -08:00
tqchen
e80d3db64b [DIST] Enable multiple thread and tracker, make rabit and xgboost more thread-safe by using thread local variables. 2016-03-03 20:36:14 -08:00
Tianqi Chen
12dc92f7e0 Merge pull request #906 from CodingCat/style
apply google-java-style indentation and impose import orders
2016-03-03 14:39:05 -08:00
CodingCat
e3dc67c6a0 apply google-java-style indentation and impose import orders.... 2016-03-03 12:59:18 -05:00
Tianqi Chen
0f367a6ade Merge pull request #904 from tqchen/master
[JVM-PKG] Update JNI to include Rabit interface
2016-03-02 22:44:46 -08:00
tqchen
c428a93adc [JVM-PKG] add distributed test simple case 2016-03-02 22:27:55 -08:00
tqchen
5c9e50148a [JVM-PKG] Update JNI to include rabit codes 2016-03-02 22:12:17 -08:00
tqchen
ced6d45e01 Update rabit 2016-03-02 20:53:34 -08:00
Tianqi Chen
0515e4ec28 Merge pull request #903 from CodingCat/jvm_package
add test cases for Scala API
2016-03-02 16:28:36 -08:00
CodingCat
8c220f51fc add default values for Scala API 2016-03-02 17:21:42 -05:00
CodingCat
cbf5eba9c0 add maven-assembly plugins 2016-03-02 17:11:15 -05:00
Nan Zhu
8e0c3b08c7 Merge branch 'master' into jvm_package 2016-03-02 15:26:39 -05:00
CodingCat
5e309f1ce8 add test cases for Scala API 2016-03-02 15:24:13 -05:00
Tianqi Chen
7d9457d72f Merge pull request #890 from CodingCat/jvm_package
[WIP] refactor xgboost4j to create jvm-packages
2016-03-01 21:01:01 -08:00
CodingCat
f8fff6c6fc rename files/packages 2016-03-01 23:48:35 -05:00
CodingCat
55e36893cd add style check for java and scala code 2016-03-01 20:53:50 -05:00
CodingCat
3b246c2420 re-structure Java API, add Scala API and consolidate the names of Java/Scala API 2016-03-01 20:53:41 -05:00
Tianqi Chen
fc4c88fceb Merge pull request #897 from tqchen/master
[PYTHON-DIST] Distributed xgboost python training API.
2016-02-29 17:11:00 -08:00
Tianqi Chen
ec9df13c70 Merge pull request #898 from maximsch2/patch-1
Describe colsample_bylevel
2016-02-29 17:01:59 -08:00
Maxim Grechkin
ba805d0fca Describe colsample_bylevel 2016-02-29 16:59:58 -08:00
tqchen
ecb3a271be [PYTHON-DIST] Distributed xgboost python training API. 2016-02-29 16:54:13 -08:00
Yuan (Terry) Tang
51bb556898 Merge pull request #895 from terrytangyuan/sklearn
Fixed #858: Separate dependencies and lightweight test env for Python
2016-02-29 11:26:11 -06:00
terrytangyuan
ae3962f757 Exclude osx for lightweight python test 2016-02-29 11:01:28 -06:00
Yuan (Terry) Tang
fdd520d774 Merge branch 'master' into sklearn 2016-02-29 10:50:55 -06:00
Tianqi Chen
728b65cec0 Merge pull request #880 from pauloalves86/master
Improve compatibility with sklearn
2016-02-29 08:37:53 -08:00
Paulo Alves
3d56caaab5 dmlc-core updated 2016-02-29 09:32:50 -03:00
Paulo Alves
b7985466a4 Merge remote-tracking branch 'upstream/master' 2016-02-29 08:53:48 -03:00
terrytangyuan
803a6fe474 Separate dependencies and lightweight test env for Python 2016-02-28 20:11:10 -06:00
Tianqi Chen
5f70b4df7a Merge pull request #891 from tqchen/master
[PYTHON] Simplify training logic, update rabit lib
2016-02-28 14:10:21 -08:00
tqchen
4a16b729fc [PYTHON] Simplify training logic, update rabit lib 2016-02-28 13:20:55 -08:00
Tianqi Chen
a868d803d0 Merge pull request #886 from zhengruifeng/mlog
add url for mlogloss
2016-02-28 09:27:26 -08:00
Ruifeng Zheng
07ed143cd6 Merge branch 'master' into mlog 2016-02-28 10:43:41 +08:00
Zheng RuiFeng
c7dc0cb50e update dmlc-core 2016-02-28 10:34:45 +08:00
Tianqi Chen
19f5f027a6 Merge pull request #889 from tqchen/master
[TEST] Fix travis test when reading hdfs
2016-02-27 18:15:52 -08:00
tqchen
90bc7f8f6b [TEST] Fix travis test when reading hdfs 2016-02-27 18:15:32 -08:00
Tianqi Chen
38ba66a5bd Merge pull request #887 from vatsan/patch-1
Plugging in gp_xgboost_gridsearch
2016-02-26 21:08:24 -08:00
Srivatsan Ramanujam
44d5ac7d37 Plugging in gp_xgboost_gridsearch 2016-02-26 19:15:32 -08:00
Tianqi Chen
758a77de9c Fix testcase after update and allow hdfs load 2016-02-26 17:04:51 -08:00
Tianqi Chen
be810e4f16 Merge pull request #885 from ChrisBarker-NOAA/patch-1
fix PyPi Description issue
2016-02-26 16:54:55 -08:00
Chris Barker
ed5781fa55 fix PyPi Description issue
the description field was set to what should be the long_description field -- making a bit of a mess on PyPi
2016-02-26 16:54:13 -08:00
Zheng RuiFeng
edf68b5933 add url for mlogloss 2016-02-26 20:46:40 +08:00
Paulo Alves
592004b38f XGBClassifier.feature_importances_ compatible with sklearn RFECV 2016-02-26 08:56:07 -03:00
Paulo Alves
81257dcfb4 Update upstream 2016-02-26 08:52:57 -03:00
Tianqi Chen
84e9ca000e Update README.md 2016-02-25 22:01:46 -08:00
Tianqi Chen
c15b7aa9cc Update index.md 2016-02-25 22:01:23 -08:00
Tianqi Chen
c50df8f3b5 Merge pull request #878 from tqchen/master
temp compatibility with sklearn
2016-02-25 21:57:45 -08:00
tqchen
ebc802756f temp compatibility with sklearn 2016-02-25 21:57:00 -08:00
Tianqi Chen
7b9cee3cbd Merge pull request #877 from tqchen/master
[DIST] Add Distributed XGBoost on AWS Tutorial
2016-02-25 21:52:13 -08:00
tqchen
a71ba04109 [DIST] Add Distributed XGBoost on AWS Tutorial 2016-02-25 21:51:37 -08:00
Tianqi Chen
61d9edcaa4 Merge pull request #867 from wyj2046/master
cause this code test pickle the booster, so change bst2 -> bst3
2016-02-25 20:25:47 -08:00
Tianqi Chen
1e435ee3ec Update README.md 2016-02-25 17:18:07 -08:00
Tianqi Chen
eae0aa256e Update README.md 2016-02-25 17:17:28 -08:00
Tianqi Chen
1176f9ac1b Merge pull request #876 from tqchen/master
[DOC] reorg docs
2016-02-25 14:08:48 -08:00
tqchen
6b02317ea8 [DOC] reorg docs 2016-02-25 14:08:30 -08:00
Tianqi Chen
76c320e9f0 Merge pull request #875 from tqchen/master
Fix model save problem in YARN
2016-02-25 13:15:52 -08:00
tqchen
02e98e5d45 [CLI] Fix model save problem 2016-02-25 13:15:23 -08:00
tqchen
d66c17881e Update readme 2016-02-25 13:11:51 -08:00
Tianqi Chen
17b5ca7351 Merge pull request #872 from tqchen/master
[TRAVIS] Fix script
2016-02-25 12:39:49 -08:00
tqchen
b69219df05 [doc] update news 2016-02-25 12:38:47 -08:00
tqchen
80239aaf00 [TRAVIS] Fix script 2016-02-25 12:17:40 -08:00
Tianqi Chen
bb0d163d22 Merge pull request #860 from zhengruifeng/mae
Add "mean absolute error" to metrics
2016-02-25 12:17:03 -08:00
Tianqi Chen
4c40fdb73a Merge pull request #864 from phunterlau/master
Awesome-XGBoost page
2016-02-25 12:15:15 -08:00
phunterlau
80595d6cc5 move TOC under title 2016-02-25 11:32:11 -08:00
Yuan (Terry) Tang
319091b3f4 Merge pull request #868 from catena/master
minor fix: in sklearn.py return attribute best_ntree_limit if early stopped
2016-02-25 07:26:43 -06:00
catena
790dc877c3 return best_ntree_limit if early stopped 2016-02-25 13:42:19 +05:30
王煜杰
d52d0ee9ed cause this code test pickle the booster, so change bst2 -> bst3 2016-02-25 14:49:33 +08:00
phunterlau
ef7d26eb07 add TOC, simplied text in the solution section 2016-02-24 21:56:51 -08:00
phunterlau
d9614dfbe8 Awesome-XGBoost, first commit 2016-02-24 17:36:20 -08:00
Tianqi Chen
cdbafafc04 Merge pull request #848 from Kontinuation/master
Minor fix on installation guide and (the probably deprecated) build script
2016-02-24 16:33:32 -08:00
Kontinuation
54a9f30e92 Minor fix on installation guide and (the probably deprecated) build script 2016-02-24 12:46:37 +08:00
Ruifeng Zheng
10af94c77e Merge branch 'master' into mae 2016-02-24 11:28:55 +08:00
Zheng RuiFeng
2c7c27e297 create mae 2016-02-24 11:15:31 +08:00
Tianqi Chen
b3a81a216d Merge pull request #859 from thirdwing/master
[Doc] documents update. close #821
2016-02-23 18:39:36 -08:00
Qiang Kou
1cc0a44264 [Doc] documents update:
(1) install_github is not support due to the usage of submodule

(2) remove part of the markdown which is not displayed correctly, see
https://xgboost.readthedocs.org/en/latest/R-package/discoverYourData.html
2016-02-23 14:49:12 -05:00
Tianqi Chen
d063eaccb1 Delete training.py 2016-02-23 08:48:50 -08:00
Tianqi Chen
49f6b384e3 Merge pull request #849 from ivallesp/master
Request for solving the problem in the tests of my contribution
2016-02-20 19:29:04 -08:00
ivallesp
c17d0ef560 changed the param show_progress by verbose_eval in cv and aggcv functions 2016-02-21 01:28:55 +01:00
Tianqi Chen
532615a32a Merge pull request #827 from ivallesp/master
Muting the remaining messages when show_progress=False
2016-02-19 08:16:25 -08:00
ivallesp
ed5c98f0ee re-using the verbose-eval parameter in the cv and aggcv methods and tests adapted 2016-02-19 17:14:57 +01:00
Yuan (Terry) Tang
c7f2f3f5b7 Merge pull request #845 from thirdwing/master
[Documents] update windows instructions
2016-02-18 18:48:37 -06:00
Qiang Kou
41052f0d6e update windows instructions 2016-02-18 16:36:04 -08:00
Yuan (Terry) Tang
75d23c8bb2 Merge pull request #833 from AlexisMignon/master
Added the possibility to use custom objective function in the sklearn…
2016-02-18 09:36:38 -06:00
Alexis Mignon
a46706c82e Merge branch 'master' into master 2016-02-17 09:35:30 +01:00
Tianqi Chen
2baea12d97 Merge pull request #818 from webgeist/master
Add feature_importances_ property for XGBClassifier
2016-02-16 10:19:04 -08:00
Yuan (Terry) Tang
ba4ec551ed Merge pull request #836 from hetong007/master
fix cran, update R-package version to 0.4-3
2016-02-16 09:28:31 -06:00
hetong007
371ff20a3b fix cran, update version to 0.4-3 2016-02-16 20:37:26 +08:00
Alexis Mignon
52e9085579 Merge branch 'master' of github.com:AlexisMignon/xgboost 2016-02-16 11:00:57 +01:00
Alexis Mignon
6e27d7539f - Added test cases for the use of custom objective functions
- Made the indentation more consistent with pep8
2016-02-16 10:59:25 +01:00
Alexis Mignon
07bd149b68 Created decorator function so that custom objective function passed to the constructor are more consistent with the sklearn conventions. Added comments in the doc string 2016-02-16 10:58:22 +01:00
Alexis Mignon
5c29eeac18 Merge branch 'master' into master 2016-02-16 10:16:58 +01:00
Yuan (Terry) Tang
29c7cfcbbf Merge pull request #823 from Far0n/py_cv
stratified cv for python wrapper
2016-02-15 13:22:55 -06:00
Alexis Mignon
c8714f587a Added the possibility to use custom objective function in the sklearn API 2016-02-15 17:13:13 +01:00
Faron
4b3a053913 stratified cv for python wrapper
finalize docstring
2016-02-15 16:06:17 +01:00
Yuan (Terry) Tang
9b2b81e6a4 Merge pull request #830 from fsimond/patch-1
Fix CV which was monitoring train-metric
2016-02-15 06:09:39 -06:00
Florian
2443cb9ca8 Fix CV which was monitoring train-metric
https://github.com/dmlc/xgboost/issues/807
2016-02-15 12:00:35 +01:00
Tianqi Chen
70d9732765 Merge pull request #816 from tqchen/master
[DISK] Major improvements in external memory, add support to group back
2016-02-10 15:31:20 -08:00
tqchen
413f119c7e Update dmlc-core 2016-02-10 13:11:21 -08:00
Pavel Gladkov
31c0408cb4 add feature_importances_ property for XGBClassifier 2016-02-10 23:01:33 +03:00
tqchen
63c4ad7617 [APPROX] Make global proposal default, add group ptr solution 2016-02-10 11:19:10 -08:00
tqchen
ce4d59ed69 [TREE] Enable global proposal for faster speed 2016-02-10 11:19:10 -08:00
tqchen
2f2080a337 [TREE] Remove gap constraint, make tree construction more robust 2016-02-10 11:17:54 -08:00
Ubuntu
c36195795a increase shard 2016-02-10 11:17:18 -08:00
Ubuntu
724eda2435 remove reserve for more aggressive memory generation 2016-02-10 11:17:18 -08:00
Ubuntu
46be6181b5 [DIST] fix distirbuted setting 2016-02-10 11:17:18 -08:00
tqchen
5218438716 [DMLC] update dmlccore 2016-02-10 11:17:18 -08:00
tqchen
b27b51f60e [PLUGIN] Add densify parser 2016-02-10 11:17:18 -08:00
tqchen
88e362732f [DMLC] Update dmlc 2016-02-10 11:17:17 -08:00
tqchen
a500fbc9b0 [TREE] switch to two pass 2016-02-10 11:17:17 -08:00
tqchen
523afcbcd2 [TREE] Cleanup some functions, add utility function for two pass 2016-02-10 11:17:17 -08:00
tqchen
52227a8920 [TREE] Refactor histmaker 2016-02-10 11:17:17 -08:00
tqchen
468bc7725a [METRIC] change metric accumulator to double 2016-02-10 11:17:17 -08:00
tqchen
88447ca32e [MEM] Add rowset struct to save memory with billion level rows 2016-02-10 11:17:17 -08:00
tqchen
2230f1273f [DISK] Add shard option to disk 2016-02-10 11:17:17 -08:00
Tianqi Chen
72961d914b Merge pull request #812 from samuel-liyi/master
fsplit value
2016-02-08 09:16:40 -08:00
Yuan (Terry) Tang
5345990dae Merge pull request #813 from angadgill/patch-2
Update build.md
2016-02-08 08:18:52 -06:00
Angad Gill
c9e09c9875 Update build.md
Minor typo
2016-02-08 01:20:43 -08:00
samuel-liyi
d3540aacc5 change the formula of fsplit value 2016-02-08 15:00:04 +08:00
Tianqi Chen
eb169e4f73 Merge pull request #788 from maximsch2/fix-missing
Make missing handling consistent with sklearn's portion of the Python package
2016-01-28 21:14:31 -08:00
Maxim Grechkin
f5e96eba72 Make missing handling consistent with sklearn's portion of the python package 2016-01-28 14:16:11 -08:00
Yuan (Terry) Tang
21d5ec7275 Merge pull request #778 from dmlc/terrytangyuan-patch-1
Update installation instructions for R package
2016-01-24 23:44:43 -06:00
Yuan (Terry) Tang
be58d6f9d6 Update installation instructions for R package 2016-01-24 19:38:36 -06:00
Yuan (Terry) Tang
5d9b80cd8b Merge pull request #774 from thirdwing/master
[R] update doc (close #760, close #773)
2016-01-24 12:19:07 -05:00
Qiang Kou
bdeb095a7d [R] update doc; add drat repo 2016-01-24 11:42:24 -05:00
Tianqi Chen
1ab0c3c248 Merge pull request #768 from moutai/patch-1
[docs] Fix typo in release notes
2016-01-21 09:55:42 -08:00
Moussa Taifi
51f0e469cb [docs] Fix typo in release notes
small typo fix
thanks
2016-01-21 10:22:11 -05:00
Yuan (Terry) Tang
015c3e0b45 Merge pull request #767 from jenshaase/patch-1
Python Package Installation Documentation Bug
2016-01-21 09:13:21 -06:00
Jens Haase
3077571976 Python Package Installation Documentation Bug 2016-01-21 15:53:18 +01:00
Tianqi Chen
52c8d09ba8 Update build.md 2016-01-20 11:40:29 -08:00
Tianqi Chen
e5b1bd39a0 Merge pull request #761 from aayush26/patch-1
line 100: path changed updated
2016-01-20 10:01:42 -08:00
Tianqi Chen
6f5b68095b Merge pull request #763 from bzEq/issue751
fix signature of __deepcopy__ method
2016-01-20 10:01:32 -08:00
Kai Luo
d9e50fd7f3 __copy__ calls __deepcopy__ with an argument 2016-01-20 19:57:20 +08:00
Kai Luo
5cd765e935 fix signature of __deepcopy__ method 2016-01-20 17:18:11 +08:00
Aayush Kumar Singha
5af97e5e47 line 100: path changed updated 2016-01-20 07:17:02 +05:30
Tianqi Chen
ef4dcce737 Merge pull request #759 from dmlc/brick
Merge Brick into master
2016-01-19 09:24:58 -08:00
Tianqi Chen
fb0ced2639 Merge pull request #755 from tqchen/brick
Brick
2016-01-16 11:52:59 -08:00
tqchen
8e7f2679d5 [DOC] Update R doc 2016-01-16 11:52:33 -08:00
tqchen
e7d8ed71d6 [DOC] cleanup distributed training 2016-01-16 11:00:40 -08:00
tqchen
df7c7930d0 [WINDOWS] Remove windows 2016-01-16 10:30:07 -08:00
tqchen
219e58d453 Minor wordings to doc 2016-01-16 10:25:12 -08:00
tqchen
1495a43cea [R] make all customizations to meet strict standard of cran 2016-01-16 10:25:12 -08:00
tqchen
634db18a0f [TRAVIS] cleanup travis script 2016-01-16 10:25:12 -08:00
tqchen
fd173e260f [FIX] change evaluation to more precision 2016-01-16 10:25:12 -08:00
tqchen
67fbf8d264 [TEST] add partial load option 2016-01-16 10:25:12 -08:00
tqchen
6de1c86d18 [LZ4] enable 16 bit index 2016-01-16 10:25:11 -08:00
tqchen
c4d389c5df [LZ] Improve lz4 format 2016-01-16 10:25:11 -08:00
tqchen
31d8e93ef3 [FIX] fix plugin system 2016-01-16 10:25:11 -08:00
tqchen
96f4542a67 [PLUGIN] Add plugin system 2016-01-16 10:25:11 -08:00
tqchen
36c389ac46 [DATA] Isolate the format of page file 2016-01-16 10:25:11 -08:00
黄子轩
a662340fda modify java wrapper settings for new refactor 2016-01-16 10:25:11 -08:00
tqchen
263b7befde [LOG] Simplfy README.md add change logs. 2016-01-16 10:25:11 -08:00
tqchen
2dc6c2dc52 [R] enable R compile
[R] Enable R build for windows and linux
2016-01-16 10:24:02 -08:00
tqchen
72347e2d45 [DATA] Make it fully compatible with rank 2016-01-16 10:24:01 -08:00
tqchen
ef1021e759 [IO] Enable external memory 2016-01-16 10:24:01 -08:00
tqchen
5f28617d7d [REFACTOR] completely remove old src 2016-01-16 10:24:01 -08:00
tqchen
d75e3ed05d [LIBXGBOOST] pass demo running. 2016-01-16 10:24:01 -08:00
tqchen
cee148ed64 [CLI] initial refactor of CLI 2016-01-16 10:24:01 -08:00
tqchen
0d95e863c9 [LEARNER] refactor learner 2016-01-16 10:24:01 -08:00
tqchen
4b4b36d047 [GBM] remove need to explicit InitModel, rename save/load 2016-01-16 10:24:01 -08:00
tqchen
82ceb4de0a [LEARNER] Init learner interface 2016-01-16 10:24:01 -08:00
tqchen
084f5f4715 [Make] refactor build script to use config file 2016-01-16 10:24:01 -08:00
tqchen
7e6f00ee11 [MAKE] fix makefile 2016-01-16 10:24:01 -08:00
tqchen
9042b9e2c7 [GBM] Finish migrate all gbms 2016-01-16 10:24:01 -08:00
tqchen
e4567bbc47 [REFACTOR] Add alias, allow missing variables, init gbm interface 2016-01-16 10:24:01 -08:00
tqchen
4f26d98150 [Update] remove rabit subtree, use submodule, move code 2016-01-16 10:24:01 -08:00
tqchen
d4677b6561 [TREE] finish move of updater 2016-01-16 10:24:01 -08:00
tqchen
4adc4cf0b9 [TREE] Move the files to target refactor location 2016-01-16 10:24:01 -08:00
tqchen
3128e1705b [TREE] Refactor colmaker 2016-01-16 10:24:01 -08:00
tqchen
20043f63a6 [TREE] Move colmaker 2016-01-16 10:24:01 -08:00
tqchen
c8ccb61b9e [TREE] Enable updater registry 2016-01-16 10:24:01 -08:00
tqchen
a62a66d545 [TREE] Finalize regression tree refactor 2016-01-16 10:24:01 -08:00
tqchen
844e8a153d [TREE] Refactor to new logging 2016-01-16 10:24:01 -08:00
tqchen
05115adbff [TREE] move tree model 2016-01-16 10:24:01 -08:00
tqchen
b4d0bb5a6d [METRIC] all metric move finished 2016-01-16 10:24:01 -08:00
tqchen
dedd87662b [OBJ] Add basic objective function and registry 2016-01-16 10:24:01 -08:00
tqchen
46bcba7173 [DATA] basic data refactor done, basic version of csr source. 2016-01-16 10:24:00 -08:00
tqchen
3d708e4788 latest data 2016-01-16 10:24:00 -08:00
tqchen
7ff91fe5f9 Data interface ready 2016-01-16 10:24:00 -08:00
tqchen
d530e0c14f [REFACTOR] cleanup structure 2016-01-16 10:24:00 -08:00
tqchen
5ed4dc4f60 fix makefile warning when cc is defined 2016-01-16 10:24:00 -08:00
Tianqi Chen
0dc68b1aef Update CHANGES.md 2016-01-14 15:58:02 -08:00
Yuan (Terry) Tang
98d8a8b871 Added contributor 2016-01-12 09:25:32 -06:00
Yuan (Terry) Tang
50af394272 Merge pull request #733 from damiencarol/javadocfix
[Java] Fix broken javadoc generation
2016-01-12 09:03:50 -06:00
damiencarol
375c106fcc Fix native/Native consistency in comments 2016-01-12 14:46:34 +01:00
Yuan (Terry) Tang
d1439a10a8 Update CONTRIBUTORS.md 2016-01-10 12:16:02 -06:00
Yuan (Terry) Tang
c44eb3ab91 Merge pull request #730 from ganesh-krishnan/master
Fixed off by 1 bug in early.stop.rounds in xgb.cv
2016-01-10 13:14:50 -05:00
damiencarol
fd3baf68f1 Fix warnings when generating javadoc 2016-01-09 15:53:35 +01:00
damiencarol
89216e239f Fix errors when generating javadoc 2016-01-09 15:45:13 +01:00
Ganesh
6ba53329e5 Fixed off by 1 bug in xgb.cv 2016-01-07 22:20:21 -08:00
Yuan (Terry) Tang
0958fb35ae Merge pull request #728 from yenchenlin1994/fix-doc-typo
Remove redundant word
2016-01-07 08:25:31 -06:00
YenChenLin
5a91ded214 Remove redundant word 2016-01-07 22:19:15 +08:00
Yuan (Terry) Tang
7606bf8156 Fixes #725 2016-01-06 18:21:29 -06:00
Yuan (Terry) Tang
1bd0f9eecd Merge pull request #724 from hxd1011/patch-1
Fix typo
2016-01-05 13:11:25 -06:00
hxd1011
8e9b7e2c67 Fix typo
"Until Know" to "Until Now"
2016-01-05 14:07:00 -05:00
Yuan (Terry) Tang
063bebe7d3 Merge pull request #722 from yenchenlin1994/fix-demo-regression-typo
Fix typo in demo/regression/README.md
2016-01-05 09:56:18 -06:00
YenChenLin
7ff704a13f Fix typo in demo/regression/README.md 2016-01-05 23:42:02 +08:00
Yuan (Terry) Tang
b684b5fada Merge pull request #720 from derek-damron/master
Add newline chars to early.stop.round message
2016-01-04 23:51:40 -06:00
Derek Damron
8756d5b160 Add newline char to early.stop.round message 2016-01-04 20:36:32 -08:00
Derek Damron
cd0099f2a1 Add newline char to early.stop.round message 2016-01-04 20:35:57 -08:00
Yuan (Terry) Tang
fa205cdaf8 Merge pull request #718 from kilojoules/patch-2
fix minor typo
2016-01-01 22:07:35 -06:00
Julian Quick
f51e1893fe fix minor typo 2016-01-01 20:03:45 -08:00
Tianqi Chen
da98e84b19 Merge pull request #714 from maarten-keijzer/doc_fix
Updated the documentation for 'gradient' and 'Hessian' (subscript error)
2015-12-30 11:55:14 +08:00
Maarten Keijzer
a6c35a8d74 Updated the documentation for 'gradient' and 'Hessian' (subscript error) 2015-12-29 15:28:43 +01:00
Yuan (Terry) Tang
d747649892 Merge pull request #712 from Far0n/py_cv
python cv bugfixing (eval metrics)
2015-12-29 07:30:26 -06:00
Yuan (Terry) Tang
ee8f189bba Merge pull request #713 from yanqingmen/java_wrapper
java wrapper modification
2015-12-29 07:18:19 -06:00
FrozenFingerz
177259a0a7 unittest for cv bugfixes added 2015-12-29 14:13:40 +01:00
yanqingmen
173ef11681 small change 2015-12-29 20:53:56 +08:00
yanqingmen
47d6d09081 add osx build instruction 2015-12-29 20:47:47 +08:00
yanqingmen
48c461ea85 change java_wrapper vs project name and script create_wrap 2015-12-29 19:50:40 +08:00
FrozenFingerz
2a46918c66 python cv bugfixing
- fixed bug if both eval_metrics xgb-param and
metrics param of cv function have been set
- cv early stopping output looks now like the one of xgb.train
2015-12-29 12:24:38 +01:00
黄子轩
2db1673585 Merge branch 'dmlc-master' into java_wrapper 2015-12-29 01:35:51 -08:00
黄子轩
4a301240bd merge from dmlc/xgboost 2015-12-29 01:34:06 -08:00
黄子轩
91fedd85b0 modify jni code 2015-12-29 01:08:19 -08:00
Tianqi Chen
4f43f1d0ac Merge pull request #711 from yoavz/tree_boosting_doc_fix
minor latex typo fix in "Introduction to Boosted Tree's" documentation
2015-12-29 08:15:32 +08:00
Yoav Zimmerman
d0ecb0cbc7 minor latex typo fix in Introduction to Boosted Tree's documentation 2015-12-28 15:42:43 -08:00
Yuan (Terry) Tang
fcb7eaa555 Merge pull request #710 from Far0n/py_cv
python cv: fixed devision by zero exception
2015-12-27 09:40:09 -06:00
FrozenFingerz
38b773d80b cv: fixed devision by zero exception
- show_progress=False or show_progress=0 led to devision by zero exception
2015-12-27 13:54:52 +01:00
Tianqi Chen
9f62553f23 Merge pull request #705 from elviswind/master
fix windows compile problem
2015-12-23 20:54:32 +08:00
junnan.wang@ef.com
dba782e985 fix windows compile problem 2015-12-23 14:33:00 +08:00
yanqingmen
4a456b2a75 small change for jni wrapper 2015-12-20 22:13:53 +08:00
huangzixuan
7d23ea7e9e add settings for OS X 2015-12-20 20:47:30 +08:00
Yuan (Terry) Tang
b942005931 Merge pull request #696 from Far0n/tc_fix
fixed wrong iter when using training continuation
2015-12-19 11:45:15 -05:00
yanqingmen
1456585249 refactor jni code and rename libxgboostjavawrapper.so to libxgboost4j.so 2015-12-19 22:26:40 +08:00
Faron
b3f3e7d0cb fixed wrong iter when using training continuation 2015-12-19 10:35:16 +01:00
Tianqi Chen
77434964ab Merge pull request #694 from khotilov/warnings_fixes
small fixes for make and gcc warnings
2015-12-19 06:50:40 +08:00
Vadim Khotilovich
f18852376f hopefully, this would make travis happy 2015-12-18 15:49:15 -06:00
Vadim Khotilovich
0c38a916fe make some gcc versions happy by using the fwrite return value 2015-12-18 15:03:39 -06:00
Vadim Khotilovich
f97c4ccb60 make gcc5 check silent when there's no gcc5 2015-12-18 14:34:16 -06:00
Vadim Khotilovich
d867579a69 make it possible to run create_wrap.sh not only from its directory 2015-12-18 14:18:28 -06:00
yanqingmen
f378fac6a1 Merge pull request #6 from dmlc/master
update
2015-12-18 14:24:08 +08:00
Yuan (Terry) Tang
4a15939c13 Merge pull request #690 from rcarneva/master
modifying cv show_progress to allow print-every-n behavior
2015-12-16 17:29:21 -06:00
Randy Carnevale
380e54a753 docstring typo 2015-12-16 17:25:55 -05:00
Randy Carnevale
0825ab36f0 updating docs for cv 2015-12-16 17:21:23 -05:00
Yuan (Terry) Tang
cfbf3595c7 Update CHANGES.md 2015-12-16 15:57:07 -06:00
Yuan (Terry) Tang
39751f8786 Merge pull request #668 from DexGroves/add-metadata
Expose model parameters to R
2015-12-16 15:55:54 -06:00
Randy Carnevale
a3fe14d6c6 modifying cv show_progress to allow print-every-n behavior 2015-12-16 16:33:01 -05:00
Groves
cd57ea2784 Add test that model paramaters are accessible within R 2015-12-16 10:24:16 -06:00
Tianqi Chen
0b17caaa27 Merge pull request #688 from khotilov/cpp_spell_doc_fixes
Spelling, wording, and doc fixes in c++ code
2015-12-12 23:22:14 -05:00
Vadim Khotilovich
b47725a65b add Eclipse stuff to .gitignore 2015-12-12 21:45:41 -06:00
Vadim Khotilovich
c70022e6c4 spelling, wording, and doc fixes in c++ code
I was reading through the code and fixing some things in the comments.
Only a few trivial actual code changes were made to make things more
readable.
2015-12-12 21:40:12 -06:00
Yuan (Terry) Tang
c56c1b9482 Merge pull request #685 from ajkl/patch-16
adding right path to setup.py
2015-12-12 20:02:42 -05:00
Ajinkya Kale
0772b51c2c minor change dir 2015-12-12 16:34:07 -08:00
Ajinkya Kale
4695fa3c2a adding right path to setup.py 2015-12-12 15:08:59 -08:00
Yuan (Terry) Tang
7a74c9523a Merge pull request #683 from terrytangyuan/pylint
Pylint Fixes
2015-12-11 19:04:38 -06:00
terrytangyuan
0eb6240fd0 Fixed all lint errors 2015-12-11 18:46:15 -06:00
terrytangyuan
a7e79e089b fix lint errors in core 2015-12-11 18:37:13 -06:00
terrytangyuan
7be496a051 ignore nested blocks 2015-12-11 18:20:35 -06:00
terrytangyuan
5f2b2a6417 Re-enable py lint test 2015-12-11 18:13:14 -06:00
terrytangyuan
c3ec8ee76f Added pylintrc file 2015-12-11 18:10:15 -06:00
Michaël Benesty
5a49eb06ca Merge pull request #682 from pommedeterresautee/master
Wording #Rstat
2015-12-10 18:54:52 +01:00
Michaël Benesty
1b07f86eb8 wording fix 2015-12-10 11:33:40 +01:00
Michaël Benesty
b2e68b8dc7 New documentation rewording 2015-12-09 18:26:56 +01:00
Michaël Benesty
2d2f92631c Merge pull request #679 from pommedeterresautee/master
Wording of R doc in new functions
2015-12-08 21:45:17 +01:00
Michaël Benesty
f761432c11 Merge remote-tracking branch 'refs/remotes/dmlc/master' 2015-12-08 18:19:25 +01:00
Michaël Benesty
fbf2707561 Wording improvement 2015-12-08 18:18:51 +01:00
Yuan (Terry) Tang
a06410055c Merge pull request #678 from phunterlau/master
update pip building, troubleshooting , and potential sklearn import error
2015-12-08 06:06:05 -06:00
pommedeterresautee
ccd4b4be00 Merge branch 'master' of https://github.com/dmlc/xgboost 2015-12-08 11:22:23 +01:00
pommedeterresautee
855be97011 model dt tree function documentation improvement 2015-12-08 11:21:25 +01:00
phunterlau
a4840b0268 update pip building, troubleshooting with new makefile, plus friendly error message when fail importing sklearn 2015-12-07 22:29:46 -08:00
Michaël Benesty
f3c5d9c1b6 Merge pull request #675 from pommedeterresautee/master
Generate new features based on tree leafs
2015-12-07 12:30:22 +01:00
Michaël Benesty
c1b2d9cb86 Generate new features based on tree leafs 2015-12-07 11:30:19 +01:00
Michaël Benesty
115c63bcde Merge remote-tracking branch 'refs/remotes/dmlc/master' 2015-12-07 11:04:46 +01:00
Yuan (Terry) Tang
162e91c5ca change .md to .rst 2015-12-06 20:25:53 -06:00
Michaël Benesty
14040123e8 Merge pull request #672 from derek-damron/patch-1
Update index.md
2015-12-07 00:08:26 +01:00
Derek Damron
ea883b30a5 Update index.md
Fixing a couple of spelling and grammatical errors.
2015-12-06 14:38:59 -08:00
Yuan (Terry) Tang
e25b2c4968 Remove redundant README 2015-12-06 11:05:44 -05:00
Michaël Benesty
3b67028ad6 remove intersect column in sparse Matrix 2015-12-05 19:02:05 +01:00
Michaël Benesty
4f4a5409d7 Merge remote-tracking branch 'refs/remotes/dmlc/master' 2015-12-05 18:30:09 +01:00
Yuan (Terry) Tang
88112f3d74 Added Apache License badge 2015-12-05 00:54:32 -05:00
Michaël Benesty
375192efa1 Merge pull request #670 from pommedeterresautee/master
Add code im demo to use the pred leaf in R
2015-12-04 16:35:43 +01:00
Michaël Benesty
2936378b76 Merge pull request #669 from dmoliveira/patch-1
Update README.md
2015-12-04 16:35:33 +01:00
pommedeterresautee
39fa45debe Add code to demo of leaf (show imprmt in accuracy) 2015-12-04 15:16:58 +01:00
Diego Marinho de Oliveira
2557d81b3b Update README.md
Link for line 26 was wrong, it pointed out again for the last demo. I was reading the readme and found the subtle inconsistence. Please, accept this minor change. It works correctly now.
2015-12-04 00:50:51 -02:00
Groves
91429bd63d Expose model parameters to R 2015-12-03 06:40:11 -06:00
pommedeterresautee
ff95d6d0ab Merge remote-tracking branch 'refs/remotes/dmlc/master' 2015-12-02 19:12:33 +01:00
Michaël Benesty
5473994a42 Merge pull request #667 from pommedeterresautee/master
change account information (pommedeterresautee)
2015-12-02 18:59:38 +01:00
Michaël Benesty
3c260c545d Merge pull request #666 from pommedeterresautee/master
Code cleaning + doc improvement #Rstat
2015-12-02 16:11:17 +01:00
pommedeterresautee
edca27fa32 Small rewording function xgb.importance 2015-12-02 15:48:22 +01:00
pommedeterresautee
db922e8c88 Small rewording function xgb.importance 2015-12-02 15:48:22 +01:00
pommedeterresautee
6ceb3438be Cleaning in documentation 2015-12-02 15:48:01 +01:00
pommedeterresautee
0abb4338a9 Cleaning in documentation 2015-12-02 15:48:01 +01:00
pommedeterresautee
7479cc68a7 Cleaning of demo 2015-12-02 15:47:45 +01:00
pommedeterresautee
e384f549f4 Cleaning of demo 2015-12-02 15:47:45 +01:00
pommedeterresautee
e57043ce62 Improve predict function documentation 2015-12-02 15:47:12 +01:00
pommedeterresautee
8233d589b6 Improve predict function documentation 2015-12-02 15:47:12 +01:00
Michaël Benesty
88e7c6012b Merge pull request #664 from pommedeterresautee/master
Support GLM in importance plot + increase tests #Rstat
2015-12-02 11:10:00 +01:00
Michaël Benesty
b708543309 Merge pull request #664 from pommedeterresautee/master
Support GLM in importance plot + increase tests #Rstat
2015-12-02 11:10:00 +01:00
pommedeterresautee
1678a6fbdb Increase cover of tests #Rstat 2015-12-02 10:40:15 +01:00
pommedeterresautee
45e6a6bbad Increase cover of tests #Rstat 2015-12-02 10:40:15 +01:00
pommedeterresautee
d04f7005de add support of GLM model in importance plot function 2015-12-02 10:39:57 +01:00
pommedeterresautee
43c860b6cc add support of GLM model in importance plot function 2015-12-02 10:39:57 +01:00
Bing Xu
5575257b08 Update README.md 2015-12-02 01:28:23 -07:00
Bing Xu
9a75daa388 Update README.md 2015-12-02 01:28:23 -07:00
Yuan (Terry) Tang
a1c0ee0e66 Merge pull request #644 from Far0n/verbose_eval_patch
small verbose_eval fixes
2015-12-01 14:58:58 -06:00
Yuan (Terry) Tang
811faa7bda Merge pull request #644 from Far0n/verbose_eval_patch
small verbose_eval fixes
2015-12-01 14:58:58 -06:00
Michaël Benesty
c870ef49da Merge pull request #662 from pommedeterresautee/master
Improve feature importance on GLM model
2015-12-01 19:02:18 +01:00
Michaël Benesty
bd2a4db26c Merge pull request #662 from pommedeterresautee/master
Improve feature importance on GLM model
2015-12-01 19:02:18 +01:00
pommedeterresautee
b05d5d3f24 Improve feature importance on GLM model 2015-12-01 18:44:25 +01:00
pommedeterresautee
28807733c3 Improve feature importance on GLM model 2015-12-01 18:44:25 +01:00
Michaël Benesty
423764ca2e Merge pull request #660 from pommedeterresautee/master
Polishing API + wording in function description #Rstat
2015-12-01 16:07:45 +01:00
Michaël Benesty
49ef81edb6 Merge pull request #660 from pommedeterresautee/master
Polishing API + wording in function description #Rstat
2015-12-01 16:07:45 +01:00
pommedeterresautee
6ce57d9cf8 Add new tests for helper functions 2015-12-01 15:44:27 +01:00
pommedeterresautee
29b73897f8 Add new tests for helper functions 2015-12-01 15:44:27 +01:00
Yuan (Terry) Tang
0ab719b59b Disable Python lint test temporarily 2015-12-01 08:39:25 -06:00
Yuan (Terry) Tang
de60db863b Disable Python lint test temporarily 2015-12-01 08:39:25 -06:00
pommedeterresautee
5d169afd7e Merge branch 'master' of https://github.com/dmlc/xgboost 2015-11-30 22:36:18 +01:00
pommedeterresautee
13a341b88d Merge branch 'master' of https://github.com/dmlc/xgboost 2015-11-30 22:36:18 +01:00
pommedeterresautee
8252d0d9f5 fix example 2015-11-30 16:33:33 +01:00
pommedeterresautee
b67902ebdd fix example 2015-11-30 16:33:33 +01:00
pommedeterresautee
2ca4016a1f fix relative to examples #Rstat 2015-11-30 16:21:43 +01:00
pommedeterresautee
425a5dd094 fix relative to examples #Rstat 2015-11-30 16:21:43 +01:00
pommedeterresautee
730bd72056 some fixes for Travis #Rstat 2015-11-30 15:47:10 +01:00
pommedeterresautee
6e370b90fd some fixes for Travis #Rstat 2015-11-30 15:47:10 +01:00
pommedeterresautee
c09c02300a Add new tests for new functions 2015-11-30 15:04:17 +01:00
pommedeterresautee
96c43cf197 Add new tests for new functions 2015-11-30 15:04:17 +01:00
pommedeterresautee
376ba6912e Update test to take care of API change 2015-11-30 14:08:27 +01:00
pommedeterresautee
ad8766dfa4 Update test to take care of API change 2015-11-30 14:08:27 +01:00
pommedeterresautee
476a6842ea Fix Rstat 2015-11-30 10:26:23 +01:00
pommedeterresautee
c5dedeb318 Fix Rstat 2015-11-30 10:26:23 +01:00
pommedeterresautee
07d62a4b89 Polishing API + wording in function description #Rstat 2015-11-30 10:22:14 +01:00
pommedeterresautee
84ab71dd7e Polishing API + wording in function description #Rstat 2015-11-30 10:22:14 +01:00
Michaël Benesty
bf19d821e0 Merge pull request #655 from pommedeterresautee/master
Add new multi tree plot function to R package
2015-11-28 18:08:27 +01:00
Michaël Benesty
09ed3f10cc Merge pull request #655 from pommedeterresautee/master
Add new multi tree plot function to R package
2015-11-28 18:08:27 +01:00
pommedeterresautee
28060d5595 Fix missing dependencies 2015-11-27 18:19:51 +01:00
pommedeterresautee
5e9f4dc973 Fix missing dependencies 2015-11-27 18:19:51 +01:00
pommedeterresautee
92e904dec9 add exclusion of global variables + generate Roxygen doc 2015-11-27 17:58:50 +01:00
pommedeterresautee
68b666d7e5 add exclusion of global variables + generate Roxygen doc 2015-11-27 17:58:50 +01:00
pommedeterresautee
2fc9dcc549 Improve description wording 2015-11-27 17:34:26 +01:00
pommedeterresautee
3d50a6a425 Improve description wording 2015-11-27 17:34:26 +01:00
pommedeterresautee
5169d08735 Add new multi.tree function to R package 2015-11-27 14:49:06 +01:00
pommedeterresautee
98ec6df168 Add new multi.tree function to R package 2015-11-27 14:49:06 +01:00
pommedeterresautee
e43830955f parameter names change in R function 2015-11-27 14:48:54 +01:00
pommedeterresautee
f28b7ed0cd parameter names change in R function 2015-11-27 14:48:54 +01:00
Michaël Benesty
9bc3d16599 Merge pull request #648 from pommedeterresautee/master
New function to plot model deepness
2015-11-24 13:52:40 +01:00
Michaël Benesty
1c4ed67779 Merge pull request #648 from pommedeterresautee/master
New function to plot model deepness
2015-11-24 13:52:40 +01:00
pommedeterresautee
6e9017c474 fix for Travis 2015-11-24 13:12:35 +01:00
pommedeterresautee
470ac2b46f fix for Travis 2015-11-24 13:12:35 +01:00
pommedeterresautee
485b30027f Plot model deepness
New function to explore the model by ploting the way splits are done.
2015-11-24 11:45:32 +01:00
pommedeterresautee
d9fe9c5d8a Plot model deepness
New function to explore the model by ploting the way splits are done.
2015-11-24 11:45:32 +01:00
Far0n
af166bf0a0 small verbose_eval fixes
- ensures same behavior for verbose_eval=0 and verbose_eval=False
- fix printing last eval message if early_stopping_rounds is set, but xgb
  runs to the end
2015-11-24 09:22:25 +01:00
tqchen
3a18b68f5f Merge commit '8ddffb36e1094e0fe3984e0eab132c23c58079a7' 2015-11-23 14:32:25 -08:00
tqchen
1b346d7041 Merge commit '8ddffb36e1094e0fe3984e0eab132c23c58079a7' 2015-11-23 14:32:25 -08:00
tqchen
8ddffb36e1 Squashed 'subtree/rabit/' changes from e81a11d..bed6320
bed6320 Merge pull request #26 from DrAndrey/master
291ab05 Remove redundant whitespace again
de25163 Remove redundant whitespace
3a6be65 Fix bug with name of sleep function

git-subtree-dir: subtree/rabit
git-subtree-split: bed63208af
2015-11-23 14:32:25 -08:00
Michaël Benesty
9cfe4bc6fe Merge pull request #647 from pommedeterresautee/master
Implement #431 PR
2015-11-23 19:47:08 +01:00
Michaël Benesty
311b1761c9 Merge pull request #647 from pommedeterresautee/master
Implement #431 PR
2015-11-23 19:47:08 +01:00
pommedeterresautee
60dd75745f Implement #431 PR 2015-11-23 18:19:59 +01:00
pommedeterresautee
fe7cdcefb4 Implement #431 PR 2015-11-23 18:19:59 +01:00
Yuan (Terry) Tang
13829329bd Merge pull request #639 from terrytangyuan/typo
Frequence to Frequency
2015-11-20 21:58:46 -06:00
terrytangyuan
51ee382517 Frequence to Frequency 2015-11-20 20:25:29 -06:00
Tianqi Chen
77fab79d83 Merge pull request #630 from sammthomson/docfix
grammar/style fixes for "Introduction to Boosted Trees" docs
2015-11-17 13:33:24 -08:00
Sam Thomson
2e9e6c82f9 grammar/style fixes for "Introduction to Boosted Trees" docs 2015-11-17 13:26:33 -08:00
Yuan (Terry) Tang
7e839c5c9e Merge pull request #627 from lenguyenthedat/patch-1
Updated build instructions for OS X.
2015-11-16 23:04:46 -06:00
Dat Le
bf50d25ea1 Updated build.md for OS X
OS X EI Capitan does not seem to stably support the clang build version anymore.
2015-11-16 10:28:12 +08:00
Yuan (Terry) Tang
83e61bf99e Merge pull request #621 from JohanManders/python-verbose-eval-extension
Python verbose_eval extension
2015-11-13 04:07:21 -06:00
Johan Manders
e68e9659ab Python verbose_eval extension
This is an extension of the verbose_eval abilities.

Removed some trailing-whitespaces
2015-11-13 08:19:44 +01:00
Yuan (Terry) Tang
cb5171914e Merge pull request #623 from sinhrks/pandas_label
Cleanup pandas support
2015-11-12 18:04:29 -06:00
sinhrks
25c4fbd0cb Cleanup pandas support 2015-11-13 06:55:04 +09:00
Yuan (Terry) Tang
4fb6153eed Fixed minor lint issue 2015-11-12 09:01:05 -06:00
Yuan (Terry) Tang
a2216c12a0 Added recent changes 2015-11-12 08:57:38 -06:00
Yuan (Terry) Tang
0a0951ba12 Clarification for best_ntree_limit 2015-11-12 08:53:45 -06:00
Yuan (Terry) Tang
42e1fd8fff Merge pull request #598 from Far0n/py_train
best_ntree_limit attribute & training continuation bugfix
2015-11-12 06:16:19 -06:00
Yuan (Terry) Tang
309fb90a5d Merge pull request #618 from phunterlau/master
fix pushd problem of pip building, convert README to rst for PyPI
2015-11-12 06:11:07 -06:00
Faron
7f2628acd7 unittest for 'num_class > 2' added 2015-11-12 08:23:11 +01:00
phunterlau
ee4096d23e fix pushd problem of pip building, convert README to rst for PyPI 2015-11-11 23:03:07 -08:00
Yuan (Terry) Tang
7b3fd92015 Added PyPI badges 2015-11-10 18:23:39 -06:00
Far0n
ce5930c365 best_ntree_limit attribute added
- best_ntree_limit as new booster atrribute added
- usage of bst.best_ntree_limit in python doc added
- fixed wrong 'best_iteration' after training continuation
2015-11-10 15:37:22 +01:00
Yuan (Terry) Tang
f91ce704f3 Merge pull request #615 from antonymayi/master
python 2.6 compatibility tweak
2015-11-10 08:26:12 -06:00
antonymayi
8c7b18daed python 2.6 compatibility tweak
replacing set literal {} with set() for python 2.6 compatibility (plus reformatting the line)
2015-11-10 14:50:54 +01:00
Yuan (Terry) Tang
d1969b4c03 Update CHANGES.md 2015-11-09 18:13:44 -06:00
Yuan (Terry) Tang
1dd96b6cdc Merge pull request #597 from JohanManders/python-pandas-dtypes
Python pandas dtypes
2015-11-09 18:08:41 -06:00
Yuan (Terry) Tang
7491413de5 Merge pull request #611 from antonymayi/master
python 2.6 compatibility
2015-11-09 08:45:26 -06:00
antonymayi
7114d6681a Update training.py
pylint compliancy
2015-11-09 15:09:14 +01:00
antonymayi
34e01642ca Update training.py
avoid dict comprehension for python 2.6 compatibility
2015-11-09 14:26:16 +01:00
Yuan (Terry) Tang
b8bc85b534 Clarification for learning_rates 2015-11-08 21:10:04 -06:00
Tong He
4db3dfee7d Update utils.R 2015-11-08 18:08:51 -08:00
Yuan (Terry) Tang
ae31bc21bc Merge pull request #610 from Far0n/master
grammar correction
2015-11-08 15:06:20 -05:00
Faron
b2f98db74e grammar correction 2015-11-08 21:00:16 +01:00
Yuan (Terry) Tang
bde25d6694 Added recent changes 2015-11-08 14:57:36 -05:00
Yuan (Terry) Tang
e837b339cc Reformat CHANGES.md 2015-11-08 14:54:52 -05:00
Yuan (Terry) Tang
01053f8f2f Merge pull request #594 from Far0n/feval
python: multiple eval_metrics changes
2015-11-08 10:10:28 -05:00
Yuan (Terry) Tang
8fc5693ef6 Merge pull request #609 from Far0n/cv_early_stopping_unittest
python: unittest for early stopping of cv
2015-11-08 09:59:18 -05:00
FrozenFingerz
3d36fa8f4e python: unittest for early stopping of cv 2015-11-08 11:42:57 +01:00
FrozenFingerz
b59018aa05 python: multiple eval_metrics changes
- allows feval to return a list of tuples (name, error/score value)
- changed behavior for multiple eval_metrics in conjunction with
early_stopping: Instead of raising an error, the last passed evel_metric
(or last entry in return value of feval) is used for early stopping
- allows list of eval_metrics in dict-typed params
- unittest for new features / behavior

documentation updated

- example for assigning a list to 'eval_metric'
- note about early stopping on last passed eval metric

- info msg for used eval metric added
2015-11-08 11:23:54 +01:00
Michaël Benesty
282a64c252 Merge pull request #608 from ClimbsRocks/patch-8
minor formatting update
2015-11-08 08:42:27 +01:00
Michaël Benesty
5268c19b6b Merge pull request #607 from ClimbsRocks/patch-7
punctuation update
2015-11-08 08:41:03 +01:00
Michaël Benesty
f5659e17d5 Merge pull request #605 from pommedeterresautee/master
Rewrite Viz function
2015-11-08 08:40:22 +01:00
Preston Parry
af047e9f8c minor formatting update 2015-11-07 22:32:18 -08:00
Preston Parry
d25efb6468 punctuation update 2015-11-07 22:27:39 -08:00
Yuan (Terry) Tang
ebbde5c343 Merge pull request #606 from cauldnz/patch-1
Fixing broken link for R sample.
2015-11-08 00:21:54 -05:00
Chris Auld
e74628f5d4 Update README.md
Fixed broken link for R 'First N Trees' sample.
2015-11-07 20:26:32 -08:00
unknown
7cb34e3ad6 Fix some bug + improve display + code clean 2015-11-07 22:24:37 +01:00
unknown
996645dc17 Change the way functions are called 2015-11-07 22:04:54 +01:00
unknown
77ae180d3d Remove DiagrammeR dependency to make travis happy... 2015-11-07 21:46:08 +01:00
unknown
0052b193cf Update lib version dependencies (for DiagrammeR mainly)
Fix @export tag in each R file (for Roxygen 5, otherwise it doesn't work anymore)
Regerate Roxygen doc
2015-11-07 21:01:28 +01:00
unknown
635645c650 Rewrite tree plot function
Replace Mermaid by GraphViz
2015-11-07 21:00:02 +01:00
unknown
231a6e7aea Merge branch 'master' of https://github.com/pommedeterresautee/xgboost
# Conflicts:
#	R-package/R/xgb.model.dt.tree.R
2015-11-07 19:13:14 +01:00
Yuan (Terry) Tang
562fe8078b Added CV early stopping to CHANGES 2015-11-07 09:45:13 -05:00
Yuan (Terry) Tang
a3a4439dec Merge pull request #602 from Far0n/cv
early stopping for CV (python) issue #529
2015-11-07 09:42:54 -05:00
Faron
95cc900b1f early stopping for CV (python) 2015-11-07 09:52:36 +01:00
Yuan (Terry) Tang
190e58a8c6 Added test for maximize parameter 2015-11-04 22:25:10 -06:00
Johan Manders
5f0f8749d9 Cleaned up some code 2015-11-04 18:05:47 +01:00
Yuan (Terry) Tang
8bf6525394 Added PyPI badge to README 2015-11-04 09:19:40 -06:00
Dat Le
117f26f865 Updated build.md for OS X
Ref: https://github.com/dmlc/xgboost/issues/596
2015-11-04 13:54:56 +08:00
Johan Manders
b0f38e9352 Changed 4 tests
Changed symbol test to give error on < sign, not on = sign
Changed 3 other functions, so that float is used instead of q
2015-11-03 21:32:47 +01:00
Johan Manders
f9e1b2b7b7 Added back feature names 2015-11-03 21:26:11 +01:00
Johan Manders
96f221e0d0 Merge pull request #5 from dmlc/master
Update to latest version
2015-11-03 20:37:20 +01:00
Yuan (Terry) Tang
e436c94419 Create CHANGES.md 2015-11-03 08:32:52 -06:00
Yuan (Terry) Tang
deb802b2be Merge pull request #587 from Far0n/py_train
python training continuation & maximize parameter
2015-11-03 08:16:12 -06:00
Far0n
8e1adddc2b added unittest for training continuation 2015-11-03 14:44:17 +01:00
Far0n
b894f7c9d6 bugfix type-check xgb_model param 2015-11-03 14:43:08 +01:00
Yuan (Terry) Tang
a71ccd8372 Merge pull request #591 from terrytangyuan/test
More test coverage for Python package
2015-11-02 21:00:52 -06:00
terrytangyuan
7d297b418f Added more thorough test for early stopping (+1 squashed commit)
Squashed commits:
[4f78cc0] Added test for early stopping (+1 squashed commit)
2015-11-02 20:37:27 -06:00
terrytangyuan
166e878830 Added tests for additional params in sklearn wrapper (+1 squashed commit)
Squashed commits:
[43892b9] Added tests for additional params in sklearn wrapper
2015-11-02 19:54:36 -06:00
Yuan (Terry) Tang
430be8d4bd Merge pull request #589 from Far0n/patch-1
Update CONTRIBUTORS.md
2015-11-02 14:52:25 -06:00
Far0n
8676a1bf56 Update CONTRIBUTORS.md 2015-11-02 21:27:05 +01:00
Faron
4fe2f2fb09 python train additions
+ training continuation of existing model
+ maximize parameter just like in R package (whether  to maximize feval)
2015-11-02 21:21:05 +01:00
Yuan (Terry) Tang
7f559235be Merge pull request #586 from Far0n/sklearn_wrapper
sklearn_wrapper additions fixed #420
2015-11-02 12:07:12 -06:00
Faron
79813097b5 sklearn_wrapper additions
added output_margin & ntree_limit to predict and predict_proba
2015-11-02 17:41:30 +01:00
Yuan (Terry) Tang
e49d06c6bd Merge pull request #585 from phunterlau/master
separate setup.py from pip installation, add trouble shooting page
2015-11-02 09:45:20 -06:00
phunterlau
739b3f2c5f separate setup.py with pip installation, add trouble shooting page 2015-11-01 22:11:11 -08:00
Yuan (Terry) Tang
9e1690defe Merge pull request #582 from terrytangyuan/test
Test (eta decay) and bug fix
2015-10-31 13:07:33 -04:00
terrytangyuan
610b70b79e Suppress more evaluation verbose during training 2015-10-31 13:05:52 -04:00
terrytangyuan
15a0d27eed Fixed bug in eta decay (+2 squashed commits)
Squashed commits:
[b67caf2] Fix build
[365ceaa] Fixed bug in eta decay
2015-10-31 12:54:27 -04:00
terrytangyuan
888edba03f Added test for eta decay (+3 squashed commits)
Squashed commits:
[9109887] Added test for eta decay(+1 squashed commit)
Squashed commits:
[1336bd4] Added tests for eta decay (+2 squashed commit)
Squashed commits:
[91aac2d] Added tests for eta decay (+1 squashed commit)
Squashed commits:
[3ff48e7] Added test for eta decay
[6bb1eed] Rewrote Rd files
[bf0dec4] Added learning_rates for diff eta in each boosting round
2015-10-31 12:36:29 -04:00
terrytangyuan
c817efbd8a Fix Travis build 2015-10-30 23:41:24 -04:00
terrytangyuan
c11d6d5929 Merge branch 'master' of https://github.com/dmlc/xgboost 2015-10-30 23:01:44 -04:00
Yuan (Terry) Tang
243fd46df9 Merge pull request #581 from ThunderShiviah/patch-1
Fix minor spelling and grammar
2015-10-30 21:55:29 -04:00
Thunder Shiviah
a0c9ecd289 Fix minor spelling errors and awkward grammar. 2015-10-30 18:43:31 -07:00
terrytangyuan
e23f4ec3db Minor addition to R unit tests 2015-10-30 19:48:00 -05:00
Yuan (Terry) Tang
9cdcc8303b Update CHANGES.md 2015-10-30 10:54:29 -05:00
Yuan (Terry) Tang
c16a6222f3 Merge pull request #563 from Far0n/eta_decay
learning_rates per boosting round
2015-10-30 10:21:33 -05:00
Tianqi Chen
3e648fd1e9 Merge pull request #572 from ghosthugger/master
install xgboost so it can be imported
2015-10-29 10:59:28 -07:00
Yuan (Terry) Tang
b9a9cd9db8 Merge pull request #580 from terrytangyuan/test
Fixed most of the lint issues
2015-10-29 00:54:16 -04:00
terrytangyuan
5b9e071c18 Fix travis build (+1 squashed commit)
Squashed commits:
[9240d5f] Fix Travis build
2015-10-29 00:28:53 -04:00
Yuan (Terry) Tang
99157ae56a Merge pull request #579 from ClimbsRocks/patch-4
minor wording update
2015-10-28 23:25:17 -04:00
terrytangyuan
6024480400 Fixed most of the lint issues 2015-10-28 23:24:17 -04:00
Preston Parry
6d35bd2421 minor wording update
just clarifying some of the language describing the parameters
2015-10-28 20:10:21 -07:00
terrytangyuan
8bae715994 Lint fix on infix operators 2015-10-28 23:04:45 -04:00
Yuan (Terry) Tang
1dcedb23ec Update CONTRIBUTORS.md 2015-10-28 22:57:41 -04:00
terrytangyuan
d7fce99564 Lint fix on consistent assignment 2015-10-28 22:22:51 -04:00
Michaël Benesty
ce9d7045f9 Merge pull request #575 from ClimbsRocks/patch-2
Clarifies explanations around Data Interface code
2015-10-28 10:02:27 +01:00
Michaël Benesty
1924e16f45 Merge pull request #576 from ClimbsRocks/patch-3
fixes typo in error message
2015-10-28 10:00:54 +01:00
Preston Parry
b3bb54da73 fixes typo in error message 2015-10-27 23:34:50 -07:00
Tianqi Chen
88b4c64c0d Merge pull request #573 from ClimbsRocks/patch-1
Clarifies wording on Data Interface intro list
2015-10-27 23:01:10 -07:00
Preston Parry
89eafa1b97 Clarifies explanations around Data Interface code 2015-10-27 22:41:29 -07:00
Preston Parry
8ddb7b0152 Clarifies wording on Data Interface intro list 2015-10-27 22:35:35 -07:00
Gösta Forsum
111b04e18e Update setup.py 2015-10-27 13:47:58 +01:00
Tong He
2e31e97e54 Merge pull request #568 from terrytangyuan/test
Added test_lint.R to test code quality
2015-10-26 22:19:48 -07:00
terrytangyuan
56da375165 Added test_lint.R to test code quality 2015-10-25 20:45:04 -04:00
Tianqi Chen
3534147905 Merge pull request #564 from Far0n/sklearn_wrapper
added missing params to sklearn python wrapper
2015-10-25 12:42:08 -07:00
Faron
738e420128 correcting wrong default values 2015-10-25 11:26:33 +01:00
Faron
b80d5d6b33 fixed too long lines 2015-10-25 11:17:35 +01:00
Faron
422febd18e added missing params 2015-10-25 10:58:07 +01:00
Faron
68c9252ff7 fixed "Exactly one space required after comma" 2015-10-25 10:20:00 +01:00
Faron
a1ba608641 learning_rates per boosting round 2015-10-25 10:00:20 +01:00
Tong He
224f574420 Merge pull request #561 from terrytangyuan/test
Added test for code quality check
2015-10-24 22:27:19 -07:00
Tianqi Chen
06f502a1aa Merge pull request #549 from phunterlau/master
Fix data file shipping confusions on pip install for #463
2015-10-24 22:08:59 -07:00
Tianqi Chen
d60ee84137 Merge pull request #560 from sinhrks/plot_importance
Python: adjusts plot_importance ylim
2015-10-24 22:08:40 -07:00
terrytangyuan
139feaf97a Code: Lint fixes on trailing spaces 2015-10-24 16:50:03 -04:00
terrytangyuan
537b34dc6f Code: Some Lint fixes 2015-10-24 16:43:44 -04:00
terrytangyuan
3abbd7b4c7 Added test_lint to test code quality 2015-10-24 16:39:58 -04:00
sinhrks
1f19b78287 Python: adjusts plot_importance ylim 2015-10-25 03:16:53 +09:00
Tianqi Chen
36927632c5 Merge pull request #557 from shimo-t/patch
fix training.py and sklearn.py for evals_result in python3
2015-10-23 09:55:50 -07:00
Takahisa Shimoda
607599f2a1 fix sklearn.py for evals_result in python3 2015-10-23 05:40:31 +09:00
Takahisa Shimoda
b587dd2704 fix training.py for evals_result in python3 2015-10-23 05:37:13 +09:00
Tianqi Chen
4b4ade8342 Update CONTRIBUTORS.md 2015-10-22 08:40:36 -07:00
Tianqi Chen
d4d36eed45 Merge pull request #528 from terrytangyuan/test
More Unit Tests for Python Package
2015-10-22 08:39:32 -07:00
Tianqi Chen
cb7f331ebc Merge pull request #555 from sinhrks/plot_sklearn
Allow plot function to handle XGBModel
2015-10-22 08:39:25 -07:00
Tianqi Chen
c4181e5f2e Merge pull request #552 from yoori/perf
GBTree::Predict performance fix: removed excess thread_temp initializ…
2015-10-22 08:39:05 -07:00
terrytangyuan
ec2cdafec5 Added fixed random seed for tests (+1 squashed commit)
Squashed commits:
[76e3664] Added fixed random seed for tests
2015-10-21 23:38:41 -05:00
terrytangyuan
755072e378 Fix failed tests (+2 squashed commits)
Squashed commits:
[962e1e4] Fix failed tests
[21ca3fb] Removed one unnecessary line
2015-10-21 23:15:34 -05:00
terrytangyuan
652ff07668 Added scikit-learn from Conda 2015-10-21 21:30:11 -05:00
phunterlau
24a92808db correct print for python 3 2015-10-21 14:32:35 -07:00
sinhrks
6f046327ac Allow plot function to handle XGBModel 2015-10-22 01:00:54 +09:00
tqchen
eee3046624 [DOC] Add contributor 2015-10-20 19:44:06 -07:00
tqchen
a16289b204 Squashed 'subtree/rabit/' changes from fa99857..e81a11d
e81a11d Merge pull request #25 from daiyl0320/master
35c3b37 add retry mechanism to ConnectTracker and modify Listen backlog to 128 in rabit_traker.py
c71ed6f try deply doxygen
62e5647 try deply doxygen
732f1c6 try
2fa6e02 ok
0537665 minor
7b59dcb minor
5934950 new doc
f538187 ok
44b6049 new doc
387339b add more
9d4397a chg
2879a48 chg
30e3110 ok
9ff0301 add link translation
6b629c2 k
32e1955 ok
8f4839d fix
93137b2 ok
7eeeb79 reload recommonmark
a8f00cc minor
19b0f01 ok
dd01184 minor
c1cdc19 minor
fcf0f43 try rst
cbc21ae try
62ddfa7 tiny
aefc05c final change
2aee9b4 minor
fe4e7c2 ok
8001983 change to subtitle
5ca33e4 ok
88f7d24 update guide
29d43ab add code
fe8bb3b minor hack for readthedocs
229c71d Merge branch 'master' of ssh://github.com/dmlc/rabit
7424218 ok
d1d45bb Update README.md
1e8813f Update README.md
1ccc990 Update README.md
0323e06 remove readme
679a835 remove theme
7ea5b7c remove numpydoc to napoleon
b73e2be Merge branch 'master' of ssh://github.com/dmlc/rabit
1742283 ok
1838e25 Update python-requirements.txt
bc4e957 ok
fba6fc2 ok
0251101 ok
d50b905 ok
d4f2509 ok
cdf401a ok
fef0ef2 new doc
cef360d ok
c125d2a ok
270a49e add requirments
744f901 get the basic doc
1cb5cad Merge branch 'master' of ssh://github.com/dmlc/rabit
8cc07ba minor
d74f126 Update .travis.yml
52b3dcd Update .travis.yml
099581b Update .travis.yml
1258046 Update .travis.yml
7addac9 Update Makefile
0ea7adf Update .travis.yml
f858856 Update travis_script.sh
d8eac4a Update README.md
3cc49ad lint and travis
ceedf4e fix
fd8920c fix win32
8bbed35 modify
9520b90 Merge pull request #14 from dmlc/hjk41
df14bb1 fix type
f441dc7 replace tab with blankspace
2467942 remove unnecessary include
181ef47 defined long long and ulonglong
1582180 use int32_t to define int and int64_t to define long. in VC long is 32bit
e0b7da0 fix

git-subtree-dir: subtree/rabit
git-subtree-split: e81a11dd7e
2015-10-20 19:37:47 -07:00
tqchen
a4ac750eb1 Merge commit 'a16289b2047a7c2ec36667f6031dbb648e4d2caa' 2015-10-20 19:37:47 -07:00
yoori
981f06b9d1 style fix 2015-10-20 00:58:11 +04:00
yoori
49c1cb6990 GBTree::Predict performance fix: removed excess thread_temp initialization 2015-10-20 00:52:37 +04:00
yoori
c0853967d5 GBTree::Predict performance fix: removed excess thread_temp initialization 2015-10-20 00:06:00 +04:00
Tianqi Chen
fd8439ffbc Update param.h
enforce parallel option to 0 for now for stable result
2015-10-19 08:59:06 -07:00
Johan Manders
7c79c9ac3a Bool gets mapped to i instead of int 2015-10-19 17:36:57 +02:00
phunterlau
8ad58139cd fix pylint warnings 2015-10-18 18:55:15 -07:00
phunterlau
7b25834667 fix data file shipping confusions, force system compiling, correct libpath for pip 2015-10-18 17:28:07 -07:00
Johan Manders
66b9a72d5a Merge pull request #4 from JohanManders/JohanManders-Pandas
More Pandas dtypes and more flexible variable naming
2015-10-17 15:17:16 +02:00
Johan Manders
9bbc3901ee More Pandas dtypes and more flexible variable naming
- Pandas DataFrame supports more dtypes than 'int64', 'float64' and 'bool', therefor added a bunch of extra dtypes for the data variable.
- From now on the label variable can be a Pandas DataFrame with the same dtypes as the data variable.
- If label is a Pandas DataFrame will be converted to float.
- If no feature_types is set, the data dtypes will be converted to 'int' or 'float'.
- The feature_names may contain every character except [, ] or <
2015-10-17 15:13:42 +02:00
Johan Manders
f116722e68 Merge pull request #3 from dmlc/master
Getting latest version from dmlc
2015-10-17 14:41:13 +02:00
Tianqi Chen
8e4dc43368 Merge pull request #540 from JohanManders/quansie-python-training-patch-1
Update training.py and sklearn.py for evals_result
2015-10-16 20:42:29 -07:00
Johan Manders
00387cb645 Removed th last few trailing whitespaces 2015-10-14 14:26:18 +02:00
Johan Manders
0f8f8e05b2 One line was too long 2015-10-14 14:18:31 +02:00
Johan Manders
82c2ba4c44 Removed trailing whitespaces and Change Error to XGBoostError 2015-10-14 14:17:57 +02:00
Johan Manders
edf4595bc1 Added evals result demos 2015-10-14 13:45:59 +02:00
Johan Manders
f1e1cc28ff Access xgboost eval metrics by using sklearn 2015-10-14 13:43:14 +02:00
Johan Manders
122ec48a89 Update evals_result.py 2015-10-14 13:40:20 +02:00
Johan Manders
6e2bdcbbbc Demo for accessing eval metrics in xgboost 2015-10-14 13:22:39 +02:00
Johan Manders
67f3c687b8 Added Johan Manders to the list, asked by Tianqi Chen 2015-10-14 13:06:14 +02:00
Johan Manders
9c8420a4dc Updated the documentation a bit
Will upload some demos for guide-python later.
2015-10-14 12:53:42 +02:00
Johan Manders
e960a09ff4 Made eval_results for sklearn output the same structure as in the new training.py
Changed the name of eval_results to evals_result, so that the naming is the same in training.py and sklearn.py

Made the structure of evals_result the same as in training.py, the names of the keys are different:

In sklearn.py you cannot name your evals_result, but they are automatically called 'validation_0', 'validation_1' etc.
The dict evals_result will output something like: {'validation_0': {'logloss': ['0.674800', '0.657121']}, 'validation_1': {'logloss': ['0.63776', '0.58372']}}

In training.py you can name your multiple evals_result with a watchlist like: watchlist  = [(dtest,'eval'), (dtrain,'train')]
The dict evals_result will output something like: {'train': {'logloss': ['0.68495', '0.67691']}, 'eval': {'logloss': ['0.684877', '0.676767']}}

You can access the evals_result using the evals_result() function.
2015-10-14 12:51:46 +02:00
Johan Manders
e339cdec52 Too many branches and unused key 2015-10-12 16:47:24 +02:00
Johan Manders
40566cdbba update sklearn.py because evals_result in training.py changed
Because I changed the training.py, the sklearn.py had to be changed also to be able to read all the data form evals_result.
2015-10-12 16:31:23 +02:00
quansie
30d0d5fb96 Merge pull request #2 from quansie/quansie-python-training-patch-1
Removed extra spaces
2015-10-12 14:28:50 +02:00
quansie
b758a13813 Removed extra spaces 2015-10-12 14:26:23 +02:00
quansie
541580d157 Update training.py 2015-10-12 14:19:25 +02:00
quansie
8a484e990e Merge pull request #1 from quansie/quansie-python-training-patch-1
training.py - pass all eval_metric information to evals_result
2015-10-12 14:11:34 +02:00
quansie
1ca737ed55 Update training.py
Made changes to training.py to make sure all eval_metric information get passed to evals_result. Previous version lost and mislabeled data in evals_result when using more than one eval_metric.

Structure of eval_metric is now:
eval_metric[evals][eval_metric] = list of metrics

Example:

>>> dtrain = xgb.DMatrix('agaricus.txt.train', silent=True)
>>> dtest = xgb.DMatrix('agaricus.txt.test', silent=True)

>>> param = [('max_depth', 2), ('objective', 'binary:logistic'), ('bst:eta', 0.01), ('eval_metric', 'logloss'), ('eval_metric', 'error')]

>>> watchlist  = [(dtest,'eval'), (dtrain,'train')]
>>> num_round = 3
>>> evals_result = {}
>>> bst = xgb.train(param, dtrain, num_round, watchlist, evals_result=evals_result)

>>> print(evals_result['eval']['logloss'])
>>> print(evals_result)

Prints:

['0.684877', '0.676767', '0.668817']

{'train': {'logloss': ['0.684954', '0.676917', '0.669036'], 'error': ['0.04652', '0.04652', '0.04652']}, 'eval': {'logloss': ['0.684877', '0.676767', '0.668817'], 'error': ['0.042831', '0.042831', '0.042831']}}
2015-10-11 01:09:05 +02:00
Tong He
e9edb03eff Merge pull request #533 from kferris10/master
Switch default missing values from 0 to NA in R package
2015-10-08 10:47:28 -07:00
kferris
d5a34339e5 Updated Changes 2015-10-08 13:22:23 -04:00
kferris
32ca060094 Fix merge conflicts 2015-10-08 08:58:27 -04:00
Tong He
81d4d4d2c1 Update utils.R 2015-10-07 18:26:33 -07:00
kferris
7a94bdb60c Switch missing values from 0 to NA in R package 2015-10-07 18:51:47 -04:00
yanqingmen
3453b6e715 Merge pull request #5 from dmlc/master
update from dmlc/xgboost
2015-10-07 13:55:57 +08:00
terrytangyuan
1080dc256a Fix Travis build 2015-10-05 00:46:56 -05:00
terrytangyuan
fc5036a630 Deleted redundant blank lines 2015-10-04 23:29:40 -05:00
terrytangyuan
9d627e2567 DOC: Updated contributors.md 2015-10-04 23:26:46 -05:00
terrytangyuan
5dd23a2195 TST: Added test for parameter tuning using GridSearchCV 2015-10-04 23:16:00 -05:00
terrytangyuan
956e50686e TST: Added test for early stopping 2015-10-04 23:15:25 -05:00
terrytangyuan
412310ed04 Added test for regression ysing Boston Housing dataset 2015-10-04 23:04:23 -05:00
terrytangyuan
d20bfb12e4 Added assertions for classification tests 2015-10-04 23:01:07 -05:00
terrytangyuan
3dbd4af263 TST: Added tests for multi-class classification 2015-10-04 22:57:13 -05:00
terrytangyuan
7b9b4f821b TST: Added tests for binary classification 2015-10-04 22:53:31 -05:00
terrytangyuan
1411d3f37f TST: Added test for custom_objective function in cv 2015-10-04 22:45:10 -05:00
terrytangyuan
dfb89e3442 TST: Added test for show_stdv when using cv 2015-10-04 22:42:39 -05:00
terrytangyuan
0c360fe55f TST: Added test for fpreproc 2015-10-04 22:30:45 -05:00
Tianqi Chen
3109069019 Merge pull request #525 from sinhrks/df_columns
Python supports pd.DataFrame with non-str columns
2015-10-04 10:01:09 -07:00
sinhrks
dbcb4c8729 Support non-str column names 2015-10-04 13:30:01 +09:00
Tianqi Chen
2859c190cd Merge pull request #522 from sinhrks/pandas
python DMatrix now accepts pandas DataFrame
2015-10-02 10:19:14 -07:00
Tianqi Chen
9c39f69559 Merge pull request #524 from sinhrks/cv_pandas
Python CV returns pd.DataFrame or np.ndarray
2015-10-02 10:18:13 -07:00
sinhrks
b958c55ac6 CV returns ndarray or DataFrame 2015-10-02 22:38:03 +09:00
sinhrks
b943becc61 python DMatrix now accepts pandas DataFrame 2015-10-01 22:52:32 +09:00
Tianqi Chen
db490d1c75 Merge pull request #503 from sinhrks/feature_types
Python: Add feature_types to DMatrix
2015-09-29 14:14:48 -07:00
sinhrks
f6f3473d17 Change to properties 2015-09-28 22:36:39 +09:00
sinhrks
db692a30e5 Add feature_types 2015-09-28 22:25:35 +09:00
Tianqi Chen
b0591c8042 Merge pull request #514 from nerdcha/master
Fix makefile typo
2015-09-21 15:05:20 -07:00
Jamie Hall
f5920f8cbd Fix makefile typo 2015-09-22 07:18:15 +10:00
Tianqi Chen
05b242d542 Merge pull request #511 from nerdcha/master
Use homebrew gcc if available
2015-09-20 17:18:38 -07:00
Jamie Hall
6c3e4d7d0d Use homebrew gcc if available 2015-09-21 08:55:42 +10:00
Tianqi Chen
f28459497d fix pylint in setup 2015-09-18 20:22:54 -07:00
Tianqi Chen
e558d45208 Update .travis.yml 2015-09-18 18:45:18 -07:00
Tianqi Chen
788741bbcb Merge pull request #507 from nerdcha/master
Restore Python3 compatibility
2015-09-18 18:32:29 -07:00
Jamie Hall
0bca4c8c3b Restore Python3 compatibility 2015-09-19 10:46:57 +10:00
Tianqi Chen
5ff0fcc693 Merge pull request #504 from irachex/contributor
Add contributor
2015-09-17 19:38:22 -07:00
Huayi Zhang
c49c6565e5 Add contributor 2015-09-18 10:35:41 +08:00
Tianqi Chen
a92d21ce24 Merge pull request #502 from irachex/fix_setup
Fix python setup: avoid import numpy in setup.py
2015-09-17 09:35:46 -07:00
Tianqi Chen
808c0a6dff Merge pull request #497 from sinhrks/numpy_check
Bug: Fix numpy array check logic
2015-09-17 09:19:58 -07:00
sinhrks
f7d434aec2 Fix numpy array check logic 2015-09-17 22:51:44 +09:00
Huayi Zhang
6af98bec16 Fix python setup: avoid import numpy in setup.py
Currently `pip install xgboost` will raise traceback like this

```
Traceback (most recent call last):
  File "<string>", line 20, in <module>
  File "/tmp/pip-build-IAdqYE/xgboost/setup.py", line 20, in <module>
    import xgboost
  File "./xgboost/__init__.py", line 8, in <module>
    from .core import DMatrix, Booster
  File "./xgboost/core.py", line 12, in <module>
    import numpy as np
ImportError: No module named numpy
```

We should avoid importing numpy in setup.py and let pip install numpy and scipy automatically.
That's what `install_requires` for.
2015-09-17 14:49:19 +08:00
Tianqi Chen
cf2ec238a4 Merge pull request #496 from sinhrks/str_cln
Cleanup str roundtrip using ctypes
2015-09-16 16:01:42 -07:00
sinhrks
bb6b7ded55 Cleanup str roundtrip using ctypes 2015-09-17 04:10:19 +09:00
Tianqi Chen
bad4a27b9f Merge pull request #495 from aeeilllmrx/master
minor spelling and grammar changes
2015-09-16 08:40:51 -07:00
Tianqi Chen
f5eb345c8a Merge pull request #498 from sinhrks/check_binary
BUG: incorrect model_file results in segfault
2015-09-16 08:40:11 -07:00
sinhrks
db0c9e1c2d BUG: incorrect model_file results in segfault 2015-09-16 22:02:30 +09:00
Alex Miller
0b143e6d22 spelling changes 2015-09-16 01:39:01 -07:00
Alex Miller
7f3bc03990 spelling and grammar 2015-09-16 01:33:28 -07:00
Alex Miller
1f624a8005 Merge pull request #2 from aeeilllmrx/aeeilllmrx-spelling-and-grammar
spelling and grammar changes
2015-09-16 01:32:43 -07:00
Alex Miller
030a4e4e25 spelling and grammar changes 2015-09-16 01:23:31 -07:00
Alex Miller
16781ac8f9 Merge pull request #1 from dmlc/master
update from original
2015-09-16 01:16:31 -07:00
Tianqi Chen
ae43fd7c7a Merge pull request #488 from sinhrks/pyfeaturenames
Support feature names in Python package
2015-09-15 09:56:55 -07:00
sinhrks
6063d243eb Mac build fix 2015-09-15 18:39:06 +09:00
Tianqi Chen
bda3282f6d Merge pull request #492 from Far0n/patch-1
bugfix evals_result regex
2015-09-14 08:46:58 -07:00
sinhrks
48ac946d9f Use ctypes 2015-09-14 22:12:19 +09:00
Far0n
0406c64a5d bugfix evals_result regex 2015-09-14 11:25:41 +02:00
Tianqi Chen
b1c94c7d86 Merge pull request #490 from phunterlau/master
add static link to gcc + openmp for MAC
2015-09-13 18:06:28 -07:00
phunterlau
529b80406c switch back to dynamic build by default 2015-09-13 17:36:49 -07:00
phunterlau
13c8d2ba74 add multi-thread static link for MAC 2015-09-13 17:34:37 -07:00
Hongliang Liu
cbb52b1d5d Merge pull request #2 from dmlc/master
rebase to current dmlc official version
2015-09-13 15:01:22 -07:00
sinhrks
6506a1c490 ENH: allow python to handle feature names 2015-09-12 12:37:33 +09:00
Tong He
dd3126735b Merge pull request #482 from terrytangyuan/patch-1
Added xgboost demo using caret into README and added more explanation in the demo
2015-09-11 11:20:37 -07:00
terrytangyuan
424bcc05fa ENH: More comments and explanation on demo using xgboost from caret 2015-09-10 23:41:36 -04:00
Yuan Tang (Terry)
62e95dcc60 DOC: Added caret_wrapper.R link into demo/README.md 2015-09-10 23:23:30 -04:00
Tong He
0fe182d3c3 Merge pull request #479 from terrytangyuan/caretwrapper
ENH/DOC: Added R package demo using caret library to train xgbTree model
2015-09-10 12:26:03 -07:00
Tianqi Chen
0c0e26effa Update README.md 2015-09-08 19:45:39 -07:00
Tianqi Chen
2a8c1c677e Merge pull request #476 from terrytangyuan/patch-1
DOC: Typo in README.md in tests folder
2015-09-08 19:38:43 -07:00
Tianqi Chen
4380641714 Merge pull request #478 from terrytangyuan/tests
TST: Added some unit tests for Python
2015-09-08 19:38:30 -07:00
terrytangyuan
9ead44531e DOC: Added new demo to index 2015-09-08 10:54:07 -04:00
terrytangyuan
d3bb466026 ENH/DOC: Added R package demo using caret library to train xgbTree model 2015-09-08 10:51:20 -04:00
terrytangyuan
8196d5d680 TST: More thorough checks for Python tests 2015-09-08 10:14:28 -04:00
terrytangyuan
82a43f448e TST: Added Python test for custom objective functions 2015-09-08 09:54:38 -04:00
terrytangyuan
eb1b185d70 TST: Added glm test for Python 2015-09-08 09:47:48 -04:00
Tong He
67f40b2629 Merge pull request #475 from terrytangyuan/master
More thorough unit testing for R package
2015-09-07 20:30:10 -07:00
terrytangyuan
33f1ab3ae1 TST: Added one minor check for xgb.importance 2015-09-07 22:51:14 -04:00
terrytangyuan
fbf2a5feed DOC: Updated CONTRIBUTORS.md 2015-09-07 22:49:10 -04:00
Yuan Tang (Terry)
cb3afeec53 DOC: Typo in README.md in tests folder 2015-09-07 22:23:47 -04:00
terrytangyuan
c50cf6d7ff TST: Added test for poisson regression 2015-09-07 22:03:28 -04:00
terrytangyuan
3a49e1bdb1 TST: Added more checks for testing custom objective 2015-09-07 21:56:50 -04:00
terrytangyuan
886955148d TST: Added test for models with custom objective 2015-09-07 21:55:17 -04:00
terrytangyuan
408c3a62a8 TST: Added test for xgb.plot.tree 2015-09-07 21:49:27 -04:00
terrytangyuan
d833038ba1 TST: Added test for xgb.importance 2015-09-07 21:48:57 -04:00
terrytangyuan
78afd6c772 TST: Added test for dump 2015-09-07 21:36:52 -04:00
Tianqi Chen
f025488294 Merge pull request #473 from evilmucedin/master
make XGBClassifier.score compatible with arrays
2015-09-06 21:18:12 -07:00
Den Raskovalov
35944a13b4 make XGBClassifier.score compatible with arrays 2015-09-06 20:41:55 -07:00
Tong He
6109a70a16 Merge pull request #471 from terrytangyuan/master
TST: Added R unit test for glm
2015-09-06 20:29:37 -07:00
Yuan Tang (Terry)
339a53d9d4 fixed unit test in R 2015-09-06 20:00:25 -04:00
Tianqi Chen
b3a3228a02 Merge pull request #469 from Far0n/patch-1
alpha & lambda for gbtree
2015-09-06 12:37:56 -07:00
terrytangyuan
92b996513e TST: Added R unit test for glm 2015-09-05 22:50:27 -04:00
Far0n
cfcb1fc491 default values for gbtree: lambda=1, alpha=0 2015-09-05 21:53:37 +02:00
Far0n
a9f884bd47 alpha = 1 as default value for gbtree 2015-09-05 21:50:53 +02:00
Far0n
dbc5c9b82d alpha & lambda for gbtree
alpha & lambda descriptions to "Parameters for Tree Booster" added (issue #466)
2015-09-05 12:36:42 +02:00
unknown
3d6c831e8a add error for data.frame, add weight to xgboost 2015-09-02 21:43:23 -07:00
Tianqi Chen
baa3145817 Merge pull request #461 from okaoka/fix-parameter-typo
Fix a typo in parameter.md
2015-08-29 10:02:40 -07:00
okaoka
632fdc3e19 Fix a typo 2015-08-29 19:45:11 +09:00
hetong007
57a43e9da7 Merge branch 'master' of github.com:dmlc/xgboost 2015-08-27 16:06:36 -07:00
hetong007
5773d4d3c4 fix test 2015-08-27 16:02:41 -07:00
hetong007
4554da0537 add test module in R 2015-08-27 15:56:35 -07:00
Tong He
635c39c4c3 Update README.md 2015-08-27 15:35:53 -07:00
hetong007
b0be833c75 add save_period 2015-08-27 14:30:23 -07:00
yanqingmen
34f0b313af Merge pull request #4 from dmlc/master
update
2015-08-26 16:32:05 +08:00
Tianqi Chen
c4fa2f6110 Update model.md 2015-08-23 22:46:50 -07:00
Tong He
f305cdbf75 align formula 2015-08-23 22:31:00 -07:00
tqchen
6bcf35f2e1 minor 2015-08-23 22:06:38 -07:00
tqchen
3c114262aa Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-08-23 22:04:24 -07:00
Tianqi Chen
b8330fc58a Merge pull request #456 from phunterlau/master
add platform if statement in setup.py for pip for pull #450 issue
2015-08-23 22:04:19 -07:00
tqchen
483a7d05e9 Merge branch 'master' of ssh://github.com/dmlc/xgboost
Conflicts:
	doc/index.md
	doc/model.md
2015-08-23 22:03:50 -07:00
tqchen
8c4c754a72 update 2015-08-23 22:00:41 -07:00
phunterlau
f4a5a8b6cd switch back to the original version info 2015-08-23 21:28:13 -07:00
phunterlau
bc6e2af374 add back setup.py after conflict resolving 2015-08-23 21:25:38 -07:00
phunterlau
6231e153e6 Merge branch 'dmlc-master' 2015-08-23 21:22:08 -07:00
phunterlau
2dcf263536 Merge branch 'master' of git://github.com/dmlc/xgboost into dmlc-master
Conflicts:
	python-package/setup.py
2015-08-23 21:20:31 -07:00
phunterlau
f258a68029 add platform if statement in setup.py for pip for pull #450 issuecomment-133795287 2015-08-23 20:38:26 -07:00
hetong007
7294ac4fc9 refine model doc 2015-08-23 17:04:08 -07:00
hetong007
cc3c98d9b7 fix formula 2015-08-23 16:59:29 -07:00
hetong007
30c30d3696 modify model doc 2015-08-23 16:56:57 -07:00
hetong007
5196458305 add plot 2015-08-23 16:28:24 -07:00
hetong007
d5d48560a7 add model description 2015-08-23 16:25:28 -07:00
Tianqi Chen
32009942fd Merge pull request #455 from sinhrks/py3
Python Visualization Fix for python 3
2015-08-23 14:29:33 -07:00
sinhrks
00702dc39b Fix for python 3 2015-08-24 05:09:27 +09:00
Tianqi Chen
8e06726f6b Merge pull request #454 from VGuette/master
Missing parentheses in call to 'print'  Thanks for the contribution!
2015-08-23 09:16:16 -07:00
VGuette
10273a0288 Update setup.py 2015-08-23 11:01:43 +02:00
Tianqi Chen
19eef1d0da Merge pull request #450 from phunterlau/master
add necessary configrations for pip installation
2015-08-20 18:45:30 -07:00
Tong He
07182444d2 Update README.md 2015-08-20 13:53:20 -07:00
phunterlau
5e81a210ce polish README.md with more information for PR #450 2015-08-20 12:33:28 -07:00
phunterlau
db444c4a08 update with comments on PR #450, fixed styles and updated CHANGES and CONTRIBUTORS 2015-08-20 10:10:34 -07:00
phunterlau
70e230815b add necessary configrations for pip installation 2015-08-20 01:26:17 -07:00
Tianqi Chen
4af680c3b6 Merge pull request #439 from sinhrks/pyviz
Add visualization to python package! great job
2015-08-15 09:48:49 -07:00
sinhrks
d24b36adf9 ENH: Add visualization to python package 2015-08-16 00:57:21 +09:00
Tianqi Chen
a13a3d1552 Merge pull request #443 from jdwittenauer/master
Cleaned up guide-python directory.
2015-08-13 18:07:42 -07:00
John Wittenauer
7a3676851d Cleaned up guide-python directory. 2015-08-13 20:32:47 -04:00
Tianqi Chen
a7202ee804 Merge pull request #438 from terrytangyuan/patch-1
fixed typos in basic_walkthrough demo
2015-08-10 22:45:24 -07:00
Yuan Tang
3dd40b9f37 fixed typos in basic_walkthrough demo 2015-08-10 20:35:10 -04:00
Tianqi Chen
18e1ddec3c Merge pull request #435 from terrytangyuan/typos
fixed some typos in demos comments
2015-08-09 19:51:32 -07:00
terrytangyuan
b3bffcef34 fixed some typos in demos comments 2015-08-09 22:15:02 -04:00
El Potaeto
740db8ff02 Merge remote-tracking branch 'dmlc/master' 2015-08-05 12:07:41 +02:00
Tianqi Chen
752cf4c95d Update xgboost_R.cpp 2015-08-04 22:56:16 -07:00
Tianqi Chen
b30aa96a88 Update xgboost_R.cpp 2015-08-04 20:14:58 -07:00
tqchen
0f6ad749f5 remove debug messages fix lint 2015-08-04 19:40:30 -07:00
Tianqi Chen
f42e4932fa Merge pull request #430 from EricChenDM/master
fix SetCombine and SetPrune bug
2015-08-04 19:36:42 -07:00
EricChanBD
3d38ebbef5 fix SetCombine and SetPrune bug 2015-08-05 06:19:54 +08:00
Tianqi Chen
889887c2f1 Update README.md 2015-08-03 19:37:33 -07:00
Tianqi Chen
7fe8b95833 Update README.md 2015-08-03 19:36:29 -07:00
Tianqi Chen
bd1eaa25f2 Merge pull request #424 from ajkl/patch-14
Adding dmlc stamp
2015-08-03 19:25:30 -07:00
Ajinkya Kale
81b1befd10 Adding dmlc stamp 2015-08-03 15:46:22 -07:00
muli
64dd1973b9 align logo with title 2015-08-03 12:59:28 -04:00
Tong He
bf94add992 Update faq.md 2015-08-02 19:09:33 -07:00
Tong He
f7bb8fc10f Update README.md 2015-08-02 19:04:32 -07:00
Tong He
014fa02c6a Update README.md 2015-08-02 19:03:44 -07:00
tqchen
e8de5da3a5 Document refactor
change badge
2015-08-02 19:01:38 -07:00
tqchen
c43fee541d enable basic sphinx doc 2015-08-01 11:27:13 -07:00
tqchen
8083c30e7b quick fix of solaris problem in cranc check 2015-08-01 09:18:34 -07:00
hetong007
3a091fa302 modify desc 2015-07-31 21:33:54 +00:00
Tianqi Chen
2a01c5c865 Update CONTRIBUTORS.md 2015-07-30 22:26:10 -07:00
Tianqi Chen
362fe4e4fa Update .travis.yml 2015-07-30 22:11:27 -07:00
tqchen
60217a2c02 checkin all python 2015-07-30 22:08:48 -07:00
tqchen
c2fec29bfa python package refactor into python-package 2015-07-30 22:04:45 -07:00
Tianqi Chen
f6fed76e7e not working 2015-07-29 23:24:54 -07:00
Tianqi Chen
7560518eec sleep 2015-07-29 23:23:40 -07:00
Tianqi Chen
53107995bf give up for now 2015-07-29 22:54:21 -07:00
Tianqi Chen
264c636adf add dep 2015-07-29 22:50:23 -07:00
Tianqi Chen
f9c02aa40f final attempt 2015-07-29 22:45:28 -07:00
Tianqi Chen
11f27beccd checkin debug 2015-07-29 22:41:06 -07:00
Tianqi Chen
ebdcd94bf5 Merge pull request #418 from dmlc/travis
Travis OSX support and unfinished appveyor
2015-07-29 22:36:24 -07:00
tqchen
4a6f4eaac9 giveup for now, appveyor do not support openmp for msvc yet allow openmp to switch on 2015-07-29 22:31:35 -07:00
tqchen
ebefb78fd4 use debug 2015-07-29 22:26:21 -07:00
tqchen
73ec467dd3 final 2015-07-29 22:22:43 -07:00
tqchen
0a9c8acd6d final 2015-07-29 22:17:25 -07:00
tqchen
6f01fa50ce try disable omp 2015-07-29 22:14:38 -07:00
tqchen
67d332e0f5 ok 2015-07-29 22:01:42 -07:00
tqchen
5dab410537 ok 2015-07-29 22:00:38 -07:00
tqchen
259dea0777 incomplete appveyor 2015-07-29 21:46:41 -07:00
tqchen
e30c724bd4 ok 2015-07-29 21:39:34 -07:00
tqchen
6f4148faab ok 2015-07-29 21:37:16 -07:00
tqchen
7e16606618 ok 2015-07-29 21:36:28 -07:00
tqchen
c2c5ad2d47 finl 2015-07-29 21:35:15 -07:00
tqchen
1a91b15a6e ok 2015-07-29 21:27:40 -07:00
tqchen
bb13c2cd15 ok 2015-07-29 21:25:52 -07:00
tqchen
033a0c139e ok 2015-07-29 21:21:58 -07:00
tqchen
0d5741bc74 rest 2015-07-29 21:21:15 -07:00
tqchen
899bfbfbae rest 2015-07-29 21:19:49 -07:00
tqchen
2bf0eeb82d update appvegor 2015-07-29 21:15:25 -07:00
tqchen
c870c08b7e disable openmp in dmlc 2015-07-29 21:11:44 -07:00
tqchen
fa41fe3f13 rename 2015-07-29 21:09:42 -07:00
tqchen
8f6e5e197b ok 2015-07-29 21:07:18 -07:00
tqchen
15286523cf ok 2015-07-29 21:06:29 -07:00
tqchen
d9599f816f add appvegor 2015-07-29 21:01:53 -07:00
tqchen
6062f4dd58 update 2015-07-29 20:18:54 -07:00
tqchen
24a188588a ok 2015-07-29 20:10:29 -07:00
tqchen
2ab6907fe2 add os lrt 2015-07-29 18:45:42 -07:00
tqchen
f44511e94d fix mac build 2015-07-29 18:29:06 -07:00
tqchen
26675e6dcd Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-07-29 18:24:27 -07:00
tqchen
75c8bdf962 add osx matrix 2015-07-29 18:24:19 -07:00
Tong He
efde0eb171 enable travis on os x 2015-07-29 18:16:59 -07:00
Tong He
f4a47fa78e Merge pull request #414 from ajkl/patch-12
Fixing duplicate params in demo
2015-07-29 17:58:21 -07:00
tqchen
5f9f42292c fix sklearn best score 2015-07-29 17:49:55 -07:00
Tianqi Chen
c261b3d1f5 Merge pull request #416 from ajkl/patch-13
add setuptools info
2015-07-29 17:38:58 -07:00
Ajinkya Kale
cca955fc94 add setuptools info 2015-07-29 16:20:55 -07:00
Ajinkya Kale
0c8c231949 Fixing duplicate params in demo
Issue in "demo(package="xgboost", custom_objective)"

> bst <- xgb.train(param, dtrain, num_round, watchlist, 
+                  objective=logregobj, eval_metric=evalerror)
Error in xgb.train(param, dtrain, num_round, watchlist, objective = logregobj,  : 
  Duplicated term in parameters. Please check your list of params.
2015-07-29 14:28:34 -07:00
Tianqi Chen
d485d1849f Merge pull request #409 from ajkl/patch-11
fixing broken basic_walkthrough links
2015-07-26 21:23:12 -07:00
Ajinkya Kale
74055cc15e fixing broken basic_walkthrough links 2015-07-26 21:22:35 -07:00
Tianqi Chen
195f90159d Merge pull request #408 from ajkl/patch-10
restructuring the README with an index
2015-07-26 21:14:48 -07:00
Ajinkya Kale
fc27e2f32d adding DMLC back to the title 2015-07-26 20:31:51 -07:00
Ajinkya Kale
f2eb55683c some more links and restructuring 2015-07-26 20:30:59 -07:00
Ajinkya Kale
9a936721d8 dropping raw graphlab url 2015-07-26 20:12:51 -07:00
Tianqi Chen
eee0d5b065 Merge pull request #327 from jseabold/sklearn-eval-set
ENH: Allow early stopping through scikit-learn API
2015-07-26 11:58:45 -07:00
Tianqi Chen
b1dec917c7 Update page_fmatrix-inl.hpp 2015-07-25 21:29:46 -07:00
tqchen
0dbac3d11e fix travis 2015-07-25 21:23:40 -07:00
tqchen
f6c82d52ec make solaris happy 2015-07-25 21:17:28 -07:00
tqchen
af042f6a24 make things cxx98 compatible 2015-07-25 21:14:50 -07:00
Ajinkya Kale
cbdcbfc49c some more changes to remove redundant information 2015-07-25 12:46:28 -07:00
Ajinkya Kale
e353a2e51c restructuring the README with an index 2015-07-24 17:00:02 -07:00
hetong007
a1c7104d7f fix crash 2015-07-24 19:11:08 +00:00
unknown
198c5bb55e fix namespace and desc 2015-07-24 11:58:02 -07:00
Tianqi Chen
141f9ebf4b Update CHANGES.md 2015-07-24 08:51:05 -07:00
Michaël Benesty
f29c2f8796 Merge pull request #404 from ajkl/patch-8
moving gitter chat up
2015-07-23 15:06:55 +02:00
Michaël Benesty
5e07367979 Merge pull request #405 from ajkl/patch-9
Add license to readme
2015-07-23 10:34:45 +02:00
Ajinkya Kale
0ea5b14bd8 Update README.md 2015-07-23 01:12:33 -07:00
Ajinkya Kale
9eca9bccf4 moving gitter chat up 2015-07-22 23:18:34 -07:00
pommedeterresautee
951ba267cf move plot file 2015-07-22 23:50:54 +02:00
Michaël Benesty
1fb5c127b5 Merge pull request #399 from orenov/master
issue #368, data.table problems
2015-07-22 21:21:34 +02:00
Michaël Benesty
4a71b0ec19 Merge pull request #402 from wgstanton/patch-2
Fixed a few typos in README
2015-07-22 18:44:30 +02:00
Will Stanton
ba63b2886f Check out vs. checkout
Made it consistent across the README
2015-07-22 10:37:49 -06:00
Will Stanton
d120167725 Fixed a few typos in README 2015-07-22 09:19:22 -06:00
El Potaeto
031b34b121 Merge remote-tracking branch 'dmlc/master' 2015-07-22 13:30:38 +02:00
orenov
d8fc16538e issue #368, data.table problems 2015-07-22 12:03:01 +03:00
Tianqi Chen
80b6ec4478 update more contributor names 2015-07-21 21:31:39 -07:00
Tianqi Chen
9203d26a2f Update CONTRIBUTORS.md 2015-07-21 08:13:07 -07:00
Tianqi Chen
4cf116ceb6 Update CONTRIBUTORS.md 2015-07-20 22:58:10 -07:00
Tianqi Chen
41f30c288e Update CONTRIBUTORS.md 2015-07-20 22:56:29 -07:00
tqchen
b18c7f9466 ok 2015-07-20 22:50:59 -07:00
tqchen
d18492e751 add list of contributors 2015-07-20 22:48:45 -07:00
El Potaeto
86f9f707d8 Merge remote-tracking branch 'dmlc/master' 2015-07-15 16:00:21 +02:00
El Potaeto
0dfc443252 New projection of all trees on one 2015-07-15 15:59:36 +02:00
Tianqi Chen
71cd9b9000 Merge pull request #393 from jpata/wrapper-dict-fix
fix wrapper dict issue #392 thanks! merged
2015-07-14 08:53:37 -07:00
Joosep
be95c80aa2 fix wrapper dict 2015-07-14 11:38:38 +02:00
Tianqi Chen
b7f355fdd2 Update travis_after_failure.sh 2015-07-12 11:00:52 -07:00
Tianqi Chen
4a746be43a Update build.md 2015-07-12 10:36:16 -07:00
Tianqi Chen
44f839b896 Update README.md 2015-07-12 10:31:55 -07:00
Tianqi Chen
35638f6146 Update README.md 2015-07-12 10:27:58 -07:00
Tianqi Chen
e402d20876 Update README.md 2015-07-10 20:41:20 -07:00
Tianqi Chen
dabb36c006 Update README.md 2015-07-10 20:41:00 -07:00
Skipper Seabold
b76db01c66 STY: Fix lint errors 2015-07-08 14:29:52 -05:00
Skipper Seabold
4a37b852a0 DOC: Add early stopping example 2015-07-08 13:55:47 -05:00
Skipper Seabold
b0f7ddaa2e REF: Combine eval_metric and feval to one parameter 2015-07-08 13:55:47 -05:00
Skipper Seabold
113285e1dc DOC: Point to parameter.md for eval_metric 2015-07-08 13:55:47 -05:00
Skipper Seabold
46e9520a28 DOC: Document verbose_eval 2015-07-08 13:55:47 -05:00
Skipper Seabold
cf89ae64e2 ENH: Allow for silent evaluation 2015-07-08 13:55:47 -05:00
Skipper Seabold
3952b525b8 ENH: Allow possibly negative evaluation metrics. 2015-07-08 11:10:36 -05:00
Skipper Seabold
0f5f9c0385 ENH: Allow early stopping in sklearn API. 2015-07-08 11:10:36 -05:00
Tianqi Chen
167544d792 Merge pull request #382 from ajkl/patch-6
refs and formatting changes
2015-07-07 19:32:52 -07:00
Tianqi Chen
1fee7da16f Merge pull request #384 from ajkl/patch-7
need to load vcd if it was freshly installed
2015-07-07 19:32:28 -07:00
Tianqi Chen
048d6929f4 Merge pull request #375 from yanqingmen/java_wrapper
good job! merged
2015-07-07 19:31:54 -07:00
Ajinkya Kale
57e4f4d426 need to load vcd if it was freshly installed 2015-07-07 17:36:18 -07:00
yanqingmen
969ea57159 Update travis_java_script.sh
add "set -e"
2015-07-07 17:28:45 -07:00
Ajinkya Kale
c489ce62b2 refs and formatting changes 2015-07-07 16:36:45 -07:00
yanqingmen
fc75885e9e add travis-ci script for java wrapper 2015-07-07 19:22:51 +08:00
Tianqi Chen
28f8267563 Update README.md 2015-07-06 22:45:27 -07:00
Tianqi Chen
9ec4c43dd2 Update README.md 2015-07-06 22:44:59 -07:00
Tianqi Chen
46342d4633 checkin 2015-07-06 20:07:04 -07:00
Tianqi Chen
fd26f45208 Merge pull request #377 from ajkl/patch-3
Adding some details on nthread parameter
2015-07-06 19:58:44 -07:00
Tianqi Chen
13aff0d8cd Merge pull request #378 from ajkl/patch-4
Adding workaround for install the R-package
2015-07-06 19:55:25 -07:00
Tianqi Chen
af76bbb3f3 Merge pull request #379 from ajkl/patch-5
Adding examples on xgb.importance, xgb.plot.importance and xgb.plot tree
2015-07-06 19:55:06 -07:00
yanqingmen
0fc47f5abb add testcases 2015-07-06 18:50:46 -07:00
yanqingmen
4d382a8cc1 rename xgboosterror 2015-07-06 17:55:13 -07:00
Ajinkya Kale
364abdd6d1 Adding examples on xgb.importance, xgb.plot.importance and xgb.plot tree 2015-07-06 16:45:30 -07:00
Ajinkya Kale
761ab7c834 Adding workaround for install the R-package
I was facing this issue and this workaround worked for me. Maybe this should be moved to know issues section.
2015-07-06 14:52:38 -07:00
Ajinkya Kale
b1bcb7183b Adding some details on nthread parameter
I got this information about nthread='real cpu count' from 7cb449c4a7/java/xgboost4j-demo/src/main/java/org/dmlc/xgboost4j/demo/ExternalMemory.java (L50)
Please confirm if this note is still valid before merging this change!
2015-07-06 11:02:19 -07:00
yanqingmen
e99ab0d1dd minor fix 2015-07-06 20:56:17 +08:00
yanqingmen
f73bcd427d update java wrapper for new fault handle API 2015-07-06 02:32:58 -07:00
yanqingmen
7755c00721 Merge pull request #2 from dmlc/master
pr from origin:master
2015-07-06 09:00:42 +08:00
tqchen
a735f8cb76 quick patch threadlocal 2015-07-04 18:29:42 -07:00
tqchen
cc767add88 API refactor to make fault handling easy 2015-07-04 18:12:44 -07:00
Tianqi Chen
4d436a3cb0 Update README.md 2015-07-03 21:59:40 -07:00
Tianqi Chen
53a18635ee Merge pull request #371 from ajkl/patch-2
fixing some typos
2015-07-03 21:42:54 -07:00
tqchen
f0421e9455 last check 2015-07-03 21:27:29 -07:00
tqchen
93319841ed ok 2015-07-03 21:20:56 -07:00
tqchen
ccf21ec061 add scipy dep 2015-07-03 21:15:10 -07:00
tqchen
39913d6ee8 add scipy dep 2015-07-03 21:14:49 -07:00
tqchen
fe3464b763 update script 2015-07-03 21:11:01 -07:00
tqchen
af0a451dc4 refactor and ci 2015-07-03 21:08:36 -07:00
tqchen
59b91cf205 make python lint 2015-07-03 20:36:41 -07:00
tqchen
57ec922214 fix all cpp lint 2015-07-03 19:42:44 -07:00
tqchen
1123253f79 lint all 2015-07-03 19:35:23 -07:00
tqchen
aba41d07cd lint learner finish 2015-07-03 19:20:45 -07:00
tqchen
1581de08da fix all utils 2015-07-03 18:44:01 -07:00
tqchen
0162bb7034 lint half way 2015-07-03 18:31:52 -07:00
Ajinkya Kale
c70a73f38d fixing some typos 2015-07-01 22:35:41 -07:00
Tong He
2ed40523ab Merge pull request #369 from ajkl/patch-1
Some typo and formatting fixes
2015-07-01 13:05:31 -07:00
Ajinkya Kale
009f692f49 Some typo and formatting fixes 2015-07-01 12:12:47 -07:00
Tong He
48e19c1964 Update xgb.cv.R 2015-06-22 12:42:12 -07:00
Tong He
704d9e0a13 fix early stopping and prediction 2015-06-21 19:46:31 -07:00
Tong He
6b254ec495 Update Makefile 2015-06-21 19:25:09 -07:00
tqchen
561e51871e ok 2015-06-17 21:00:34 -07:00
Tong He
777c5ce992 temporarily do not compile vignette 2015-06-16 15:08:01 -07:00
Tong He
70c5c12067 update knitr dependency 2015-06-16 14:39:04 -07:00
Tong He
1595d36721 ask travis to compile vignette 2015-06-16 14:22:51 -07:00
pommedeterresautee
37714eb331 Merge branch 'master' of https://github.com/pommedeterresautee/xgboost 2015-06-16 21:40:09 +02:00
pommedeterresautee
ad2e93f6c5 multi tree update 2015-06-16 21:39:31 +02:00
pommedeterresautee
936190c17c slight update in documentation 2015-06-16 21:38:14 +02:00
hetong007
9987fb24f8 update makefile 2015-06-16 11:43:04 -07:00
hetong007
67f0b69a4c change makefile to be compatible with r-travis 2015-06-16 11:30:11 -07:00
Tong He
5568f83a6c Update .travis.yml 2015-06-15 22:40:15 -07:00
Tong He
b08c3c5baa Update .travis.yml 2015-06-15 22:16:11 -07:00
Tong He
7d9ac3f97d Update .travis.yml 2015-06-15 19:15:34 -07:00
hetong007
0bbb4a07b2 add travis conf, waiting for setting on travis-ci.org 2015-06-15 15:25:40 -07:00
tqchen
7a92d4008e fix col from dense 2015-06-15 09:24:10 -07:00
hetong007
c51d71b033 check duplicated params 2015-06-12 16:48:01 -07:00
Tong He
7cb449c4a7 Update xgb.cv.R 2015-06-11 14:16:20 -07:00
Tong He
61142f203b check whether objective is character 2015-06-11 14:04:43 -07:00
Tianqi Chen
fbaa3821a4 Merge pull request #351 from yanqingmen/java_wrapper
Java wrapper for xgboost
2015-06-11 09:02:32 -07:00
yanqingmen
4e8a1c6516 rm WatchList class, take Iterable<Entry<String, DMatrix>> as eval param, change Params to Iterable<Entry<String, Object>> 2015-06-10 23:34:52 -07:00
yanqingmen
8c5d3ac130 Merge branch 'java_wrapper' of https://github.com/yanqingmen/xgboost into java_wrapper 2015-06-10 20:11:11 -07:00
yanqingmen
c110111f52 make some fix 2015-06-10 20:09:49 -07:00
yanqingmen
1e03be4e08 Update Makefile 2015-06-09 23:30:00 -07:00
yanqingmen
f91a098770 add java wrapper 2015-06-09 23:14:50 -07:00
yanqingmen
fcca359774 Merge pull request #1 from dmlc/master
pull from dmlc
2015-06-10 09:09:42 +08:00
Tianqi Chen
00a8076deb Merge pull request #350 from jeremyatia/patch-1
Update understandingXGBoostModel.Rmd
2015-06-08 16:36:40 -07:00
Jeremy ATIA
a6abdccf01 Update understandingXGBoostModel.Rmd
a typo for the dimension of the test set
2015-06-08 23:31:12 +02:00
El Potaeto
ab219d3331 Merge remote-tracking branch 'dmlc/master' 2015-06-03 11:18:45 +02:00
tqchen
2937f5eebc io part refactor 2015-06-02 23:18:31 -07:00
tqchen
e5dd894960 add a indicator opt 2015-06-02 11:38:06 -07:00
Tong He
bc7f6b37b0 Update README.md 2015-05-30 17:39:19 -07:00
hetong007
36031d9a36 modify script to use objective and eval_metric 2015-05-30 15:48:57 -07:00
Tong He
27e4cbb215 Merge pull request #337 from jonrobinson2/patch-1
Update xgboostPresentation.Rmd
2015-05-28 09:32:32 -07:00
Tong He
f9ae83e951 Update xgb.cv.R 2015-05-28 09:30:23 -07:00
Jonathan Robinson
a55f4d3416 Update xgboostPresentation.Rmd
Edited to note unavailability of stable version of this package on CRAN.

http://cran.r-project.org/web/packages/xgboost/index.html
2015-05-28 09:45:46 -04:00
hetong007
733d23aef8 rename arguments to be dot-seperated 2015-05-25 11:51:01 -07:00
hetong007
8d3a7e1688 change doc and demo for new obj feval interface 2015-05-25 11:30:04 -07:00
hetong007
19b24cf978 customized obj and feval interface 2015-05-25 11:19:38 -07:00
Tong He
458585b5fd Update xgb.train.R 2015-05-25 10:24:59 -07:00
Tianqi Chen
1d57cfb7bd Update xgboost.py 2015-05-22 13:27:08 -07:00
Tianqi Chen
bc7241b2a4 Update README.md 2015-05-21 13:44:21 -07:00
Tianqi Chen
7d132aefa9 Update LICENSE 2015-05-21 13:01:15 -07:00
Tianqi Chen
a31aaa410c Update parameter.md 2015-05-20 17:27:15 -07:00
Tianqi Chen
da5e62773d Merge pull request #328 from drsaltiel/patch-1
Update parameter.md to include parameter ranges
2015-05-20 17:26:00 -07:00
Daniel Saltiel
b1c79323af Update parameter.md to include parameter ranges
only updated for tree booster parameters
2015-05-20 17:13:20 -07:00
Tianqi Chen
c82101ef16 Merge pull request #324 from jseabold/allow-zero-as-missing
ENH: Allow missing = 0
2015-05-18 18:54:17 +02:00
Skipper Seabold
978216d350 ENH: Allow missing = 0 2015-05-18 11:43:58 -05:00
Tianqi Chen
0c6bfa74b5 Merge pull request #315 from jseabold/sklearn-handle-missing
ENH: Allow settable missing value in sklearn api.
2015-05-18 17:00:53 +02:00
Tianqi Chen
01175a415a Merge pull request #323 from jseabold/fix-errors
BUG: XGBError -> XGBoostError
2015-05-18 17:00:08 +02:00
Skipper Seabold
a17cb2339e BUG: XGBError -> XGBoostError 2015-05-18 09:09:22 -05:00
Skipper Seabold
0a0a80ec72 ENH: Allow settable missing value in sklearn api. 2015-05-18 09:06:09 -05:00
tqchen
91a5390929 checkin copy 2015-05-17 21:29:51 -07:00
pommedeterresautee
1ea7f6f033 fix bug 2015-05-17 20:37:15 +02:00
pommedeterresautee
947afd7eac multi trees 2015-05-17 15:16:28 +02:00
tqchen
e6b8b23a2c allow booster to be pickable, add copy function 2015-05-16 12:59:55 -07:00
tqchen
39f1da08d2 Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-05-15 23:54:40 -07:00
tqchen
09a841f810 auto turn on optimization 2015-05-15 23:54:34 -07:00
tqchen
792cff5abc checkin some micro optimization 2015-05-15 23:54:03 -07:00
Tianqi Chen
f49525ee95 Merge pull request #319 from jdwittenauer/master
Add classes_ attribute to scikit-learn wrapper
2015-05-15 22:03:18 -07:00
John Wittenauer
4e080928a8 Added classes_ attribute to scikit-learn wrapper. 2015-05-15 21:19:39 -04:00
Tianqi Chen
9c52fc8e22 Merge pull request #314 from enizhibitsky/wrapper_stopping_fix
Fix early stopping in python wrapper
2015-05-14 16:16:47 -07:00
Tianqi Chen
019ab50994 Merge pull request #313 from alexchao56/master
Updated grammar for the README.md
2015-05-14 16:16:13 -07:00
Eugene Nizhibitsky
b63868327f Fix early stopping in python wrapper 2015-05-14 22:55:49 +03:00
Alex Chao
e080c663a8 Updated grammar for the README.md 2015-05-14 11:57:50 -07:00
tqchen
3a7808dc7d remove print 2015-05-13 23:34:09 -07:00
Tianqi Chen
49ad633530 Update xgboost.py 2015-05-13 23:15:19 -07:00
Tong He
e03ef41829 Merge pull request #312 from by321/master
xgb.cv( printEveryN ) parameter to print every n-th progress message
2015-05-13 22:18:47 -07:00
by321
a4341f22a2 xgb.csv(printEveryN) parameter to print every n-th progress message 2015-05-13 21:51:05 -07:00
tqchen
b8b0243d95 Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-05-12 20:21:00 -07:00
tqchen
62801f5343 allow fpic 2015-05-12 20:20:30 -07:00
Tianqi Chen
cb4d7f821f Update README.md 2015-05-11 23:44:02 -07:00
tqchen
42bf52f462 0.4 2015-05-11 23:42:49 -07:00
hetong
755eab8949 update date 2015-05-11 20:58:41 -07:00
hetong
c05cc48dfa delete abundant file 2015-05-11 20:55:09 -07:00
hetong007
cfdd6029a8 rename demo of early stopping 2015-05-11 16:59:18 -07:00
Tong He
d7da4189dc Merge pull request #296 from by321/master
new parameter in xgboost() and xgb.train() to print every N-th progress message
2015-05-11 16:55:14 -07:00
hetong007
90096e718c fix early stopping 2015-05-11 16:53:51 -07:00
hetong007
83ace55f51 add early stopping to xgb.cv 2015-05-11 16:03:40 -07:00
hetong007
60d307c445 add poisson demo 2015-05-11 15:21:54 -07:00
by321
5dacab0e22 new parameter in xgboost() and xgb.train() to print every N-th progress message 2015-05-11 14:18:24 -07:00
Tianqi Chen
9c0ba67088 Update README.md 2015-05-11 08:45:59 -07:00
Tianqi Chen
8b9e87790a Merge pull request #299 from jseabold/pickle-xgbooster
ENH: Pickle xgbooster enhancments. Thanks!
2015-05-11 08:44:36 -07:00
Skipper Seabold
15ea00540a EX: Make separate example for fork issue. 2015-05-11 09:30:51 -05:00
Skipper Seabold
fa8c6e2f0b DOC: Add warning about fork + openmp 2015-05-11 09:09:08 -05:00
Skipper Seabold
99c2df9913 EX: Show example of pickling and parallel use. 2015-05-11 09:09:08 -05:00
Skipper Seabold
932af821c5 CLN: Remove unused import. Fix comment. 2015-05-11 09:09:05 -05:00
Tianqi Chen
08848ab3ee Update README.md 2015-05-10 17:45:20 -07:00
Tianqi Chen
6f56e0f4ef Merge pull request #307 from pommedeterresautee/master
cleaning Rmarkdown
2015-05-10 08:51:42 -07:00
El Potaeto
3104f1f806 wording + presentation Otto rmarkdown 2015-05-10 09:39:21 +02:00
El Potaeto
cebca6846d ref in README 2015-05-10 09:38:48 +02:00
hetong007
d3564f34d5 Merge branch 'master' of github.com:dmlc/xgboost 2015-05-09 18:09:05 -07:00
hetong007
3f9921762a support both early stop name 2015-05-09 18:08:47 -07:00
tqchen
3a534d264d fix wrapper gc bug 2015-05-09 17:39:45 -07:00
tqchen
9a85c108e2 Merge branch 'master' of ssh://github.com/tqchen/xgboost 2015-05-09 17:39:11 -07:00
Tong He
f6fc38f7af Merge pull request #298 from pommedeterresautee/master
Documentation improvement
2015-05-08 15:15:56 -07:00
pommedeterresautee
11ba651a07 Regularization parameters documentation improvement 2015-05-08 16:59:29 +02:00
pommedeterresautee
e92d384a6a small change in the wording of Otto R markdown 2015-05-08 16:29:29 +02:00
tqchen
a4de0ebcd4 change numpy to bytearray as buffer 2015-05-07 18:21:15 -07:00
tqchen
6942980ebb Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-05-07 18:13:29 -07:00
tqchen
68444a0626 fix pkl problem 2015-05-07 18:11:40 -07:00
Tianqi Chen
0af5cfbac3 Merge pull request #291 from pommedeterresautee/master
Rmarkdown improvement
2015-05-07 10:28:40 -07:00
Tianqi Chen
c6c7dc0a93 Update CHANGES.md 2015-05-06 17:11:39 -07:00
Tianqi Chen
2d748fb6fa Update xgboost.py 2015-05-06 16:46:27 -07:00
tqchen
60bf389825 update version to be consistent with python 2015-05-06 16:45:05 -07:00
tqchen
594bed34e4 fix saveraw 2015-05-06 16:42:27 -07:00
tqchen
382dcf6c34 Merge branch 'jseabold-xgb-pickleable' 2015-05-06 16:08:51 -07:00
tqchen
62f938d2b4 Merge branch 'xgb-pickleable' of https://github.com/jseabold/xgboost into jseabold-xgb-pickleable 2015-05-06 16:08:48 -07:00
tqchen
3244f1e9ae Merge branch 'jseabold-xgb-pickleable' 2015-05-06 16:03:36 -07:00
tqchen
76bad1c4cc Merge branch 'xgb-pickleable' of https://github.com/jseabold/xgboost into jseabold-xgb-pickleable 2015-05-06 16:03:24 -07:00
Tong He
ba49f82ace update to 0.4 2015-05-06 15:46:15 -07:00
tqchen
ab6a3b1ee8 Merge branch 'master' of ssh://github.com/tqchen/xgboost 2015-05-06 15:43:22 -07:00
tqchen
7f7947f31c add with pbuffer info to model, allow xgb model to be saved in a more memory compact way 2015-05-06 15:43:15 -07:00
hetong007
993d7b9da3 update roxygen2 2015-05-06 15:23:37 -07:00
hetong007
419e4dbda6 add demo for early_stopping in R 2015-05-06 15:14:29 -07:00
El Potaeto
fd983dfb97 wording 2015-05-07 00:08:45 +02:00
El Potaeto
a985d7dd2b add CSS 2015-05-06 23:31:00 +02:00
Skipper Seabold
13837060f1 ENH: Don't use tempfiles for save/load 2015-05-06 15:02:26 -05:00
Skipper Seabold
11fa419720 ENH: Make XGBModel pickleable. 2015-05-06 12:37:07 -05:00
hetong007
0f182b0b66 fix logic 2015-05-05 16:44:36 -07:00
hetong007
54fb49ee5c add early stopping to R 2015-05-05 16:31:49 -07:00
Tong He
3b4697786e Merge pull request #288 from pommedeterresautee/master
small changes in RMarkdown
2015-05-05 14:58:56 -07:00
El Potaeto
8aa739d374 fix 2015-05-05 23:49:12 +02:00
El Potaeto
5eeec6a33f small changes in RMarkdown 2015-05-05 23:45:43 +02:00
Tong He
937a75bcb1 fix typo 2015-05-05 11:00:49 -07:00
Tong He
c242f9bb66 improve tree graph 2015-05-04 15:25:12 -07:00
Tianqi Chen
a3ad9df0b4 Update understandingXGBoostModel.Rmd 2015-05-04 14:27:44 -07:00
Tong He
2157146cea minor changes 2015-05-04 13:56:45 -07:00
Tianqi Chen
206f3cdbe0 msvc 2015-05-04 11:13:19 -07:00
Tianqi Chen
37d704826a Update parameter.md 2015-05-04 10:51:51 -07:00
tqchen
667a752e04 add poisson regression 2015-05-04 10:48:25 -07:00
tqchen
a310db86a1 new rmarkdown 2015-05-03 14:02:15 -07:00
tqchen
32b1d9d6b0 some minor fix 2015-05-03 13:59:38 -07:00
Tianqi Chen
a8d059902d Merge pull request #283 from pommedeterresautee/master
OTTO Rmarkdown
2015-05-03 09:09:49 -07:00
El Potaeto
1b95df4e54 parameter change in OTTO ramarkdown 2015-05-03 12:57:18 +02:00
El Potaeto
5fa2abee6e wording 2015-05-03 12:55:13 +02:00
El Potaeto
feac425851 trees 2015-05-03 12:52:43 +02:00
El Potaeto
514c5fd447 upgrade DiagrammeR to fix a bug in v 0.5 2015-05-03 12:18:44 +02:00
Tianqi Chen
5b430ee019 Update xgboost.py 2015-05-02 19:29:17 -07:00
Tianqi Chen
8c59c82d92 Merge pull request #282 from ujwlkarn/patch-1
Fixed typos and sentence structure
2015-05-02 09:07:14 -07:00
Ujjwal Karn
897180b2c6 fixed typos and sentence structure 2015-05-02 14:23:33 +05:30
Tianqi Chen
b1f489fd8b Merge pull request #281 from fyears/patch-2
update build instruction in OS X
2015-05-01 23:00:00 -07:00
fyears
5e89943ed0 update build instruction in OS X
`bash xgboost/build.sh` does not work as expected, so `cd` then `build.sh`. And remove the outdated information.
2015-05-01 22:58:53 -07:00
tqchen
5466b36ddb Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-05-01 22:46:22 -07:00
tqchen
7258f3353c Squashed 'subtree/rabit/' changes from 24f17df..fa99857
fa99857 try fix warning on some platforms

git-subtree-dir: subtree/rabit
git-subtree-split: fa99857467
2015-05-01 22:46:14 -07:00
tqchen
7297c2352f Merge commit '7258f3353c8cc3ee3dd3c00c987fa0b189e58723' 2015-05-01 22:46:14 -07:00
tqchen
869c68f149 minor 2015-05-01 22:46:06 -07:00
Tianqi Chen
90b2c0946e Merge pull request #280 from fyears/patch-1
The complete ways to install XGBoost in OS X.
2015-05-01 20:41:58 -07:00
fyears
99eaf771c4 The complete ways to install XGBoost in OS X. 2015-05-01 20:33:38 -07:00
Tianqi Chen
fe32725fa0 Update README.md 2015-05-01 15:58:51 -07:00
Tong He
4ff6697d83 Merge pull request #278 from khotilov/custom_loss_cv_fix
Improved logic in stratified CV
2015-05-01 14:46:05 -07:00
Vadim Khotilovich
c18e081f48 cleanup 2015-05-01 16:16:50 -05:00
Vadim Khotilovich
f05c7d87cb Merge remote branch 'src/master' into custom_loss_cv_fix 2015-05-01 15:42:50 -05:00
Vadim Khotilovich
0a3e7722fd a safeguard against someone using automatic folds creation with ranking 2015-05-01 15:16:30 -05:00
Vadim Khotilovich
f325930bd9 Improved logic in stratified CV to guess class/regr
Somewhat more robust and clear logic in stratified CV to guess classification/regression settings. Allows to accomodate custom objectives (classification is assumed when number of unique values in labels <= 5).
2015-05-01 15:08:08 -05:00
tqchen
2b3b55554f add parameter tunning 2015-05-01 11:41:18 -07:00
tqchen
6f0cbcaf2b add build instruction to doc 2015-05-01 11:12:43 -07:00
Tianqi Chen
8a411150ea Update sparse_batch_page.h 2015-05-01 10:55:42 -07:00
El Potaeto
d74d199a1e small change in the documentation 2015-05-01 13:03:15 +02:00
El Potaeto
962837bab7 OTTO markdown improvement 2015-05-01 13:02:43 +02:00
El Potaeto
52afe1cd7e OTTO markdown 2015-05-01 09:49:04 +02:00
El Potaeto
9f3b02cc3e multiclass documentation 2015-05-01 09:48:07 +02:00
El Potaeto
d860469030 Roxygen update 2015-05-01 09:47:18 +02:00
Tianqi Chen
654aa0b3b5 Update README.md 2015-04-30 15:45:41 -07:00
Tianqi Chen
68d9e7d673 Update README.md 2015-04-30 15:44:27 -07:00
Tong He
bab7b58d94 Merge pull request #227 from khotilov/master
add stratified cross validation for classification
2015-04-30 11:39:52 -07:00
tqchen
188d81d64a Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-04-29 20:25:06 -07:00
tqchen
c77fa7a670 Squashed 'subtree/rabit/' changes from 4fe8d1d..24f17df
24f17df ok

git-subtree-dir: subtree/rabit
git-subtree-split: 24f17df782
2015-04-29 20:23:56 -07:00
tqchen
b2bd79bc76 Merge commit 'c77fa7a670133ac40d6387cc2e958d5fc7cae8c4' 2015-04-29 20:23:56 -07:00
tqchen
18164e677a Squashed 'subtree/rabit/' changes from d1d2ab4..4fe8d1d
4fe8d1d ok io
a5d77ca checkin new dmlc interface

git-subtree-dir: subtree/rabit
git-subtree-split: 4fe8d1d66b
2015-04-29 20:22:11 -07:00
tqchen
32a7c906b4 Merge commit '18164e677af11f8d8be49c3cfb8c3960b9e800fa' 2015-04-29 20:22:11 -07:00
Tianqi Chen
d7846d0ef9 Update README.md 2015-04-28 19:14:32 -07:00
Tianqi Chen
0c7e6327fb Update README.md 2015-04-28 19:13:13 -07:00
Tianqi Chen
d4fcebf8c5 Merge pull request #274 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2015-04-28 19:12:20 -07:00
The Gitter Badger
7b730093a0 Added Gitter badge 2015-04-29 02:11:32 +00:00
Tong He
0de862cdbc Merge pull request #271 from pommedeterresautee/master
Suppress a Note in Cran check
2015-04-28 15:36:33 -07:00
tqchen
afe0a552e0 Squashed 'subtree/rabit/' changes from e1ddcc2..d1d2ab4
d1d2ab4 remove at end

git-subtree-dir: subtree/rabit
git-subtree-split: d1d2ab4599
2015-04-28 10:50:54 -07:00
tqchen
55fe810232 Merge commit 'afe0a552e0689c14c875a0da445e6e417f4ac449' 2015-04-28 10:50:54 -07:00
El Potaeto
0c8b6e2008 Suppress a Note in Cran check 2015-04-28 15:23:23 +02:00
tqchen
e63faf0e85 minor shadow fix 2015-04-27 22:52:19 -07:00
tqchen
2eccdda3c5 strict cstyle pthread 2015-04-27 22:42:01 -07:00
tqchen
279758a92e some strict cxx98 check 2015-04-27 17:37:07 -07:00
hetong007
48bcc021f7 add Rbuildignore to avoid compile .o files 2015-04-27 17:09:47 -07:00
Tianqi Chen
856a18e457 Update README.md 2015-04-27 17:07:58 -07:00
Tianqi Chen
ed901ddbb8 Update README.md 2015-04-27 17:07:28 -07:00
tqchen
69627567da adapt new dmlc io interface 2015-04-27 16:04:14 -07:00
tqchen
1e56ba86d9 Squashed 'subtree/rabit/' changes from fed1683..e1ddcc2
e1ddcc2 Merge branch 'master' of ssh://github.com/dmlc/rabit
6745667 new dmlc io
c5b4610 sge scheduler change

git-subtree-dir: subtree/rabit
git-subtree-split: e1ddcc2eb7
2015-04-27 15:58:57 -07:00
tqchen
59b96cdda5 Merge commit '1e56ba86d9d3e44b14c0a8f5ff71369307dbe86c' 2015-04-27 15:58:57 -07:00
Tianqi Chen
6783b66b9f Merge pull request #269 from jseabold/decode-string-py3
Good, python3 compatibility is indeed something we need to be careful about
2015-04-27 10:45:39 -07:00
Skipper Seabold
ee7e8b6e8a COMPAT: Decode bytes object for Python 3. 2015-04-27 12:41:24 -05:00
Tianqi Chen
f271af488b Merge pull request #267 from jseabold/add-n-classes
Add n_classes_ to fitted XGBClassifier
2015-04-27 09:10:17 -07:00
Skipper Seabold
c1a24c0fb1 ENH: Add n_classes_ to fitted classifier. 2015-04-27 11:09:55 -05:00
Tianqi Chen
8ac89b290e Merge pull request #268 from jseabold/docstrings
DOC: Add docstrings to user-facing classes.
2015-04-27 09:08:56 -07:00
Skipper Seabold
efdbec4d4c DOC: Add docstrings to user-facing classes. 2015-04-27 11:01:46 -05:00
Tianqi Chen
abcc09286c Merge pull request #265 from yzliao/master
add doc for Python wrapper
2015-04-26 22:14:05 -07:00
Yizheng Liao
bb91bdea84 add doc for Python wrapper 2015-04-26 22:08:06 -07:00
Tianqi Chen
94fac1076a bugfix setup 2015-04-26 00:17:58 -07:00
tqchen
d16b2c9670 Squashed 'subtree/rabit/' changes from 27340f9..fed1683
fed1683 minor
c01520f change

git-subtree-dir: subtree/rabit
git-subtree-split: fed1683b9b
2015-04-25 21:24:54 -07:00
tqchen
2eb30e732d Merge commit 'd16b2c9670d1849a360b94d581250aa1796d4abd' 2015-04-25 21:24:54 -07:00
tqchen
b5690e618e Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-04-25 21:20:06 -07:00
tqchen
4abd76386b Merge commit 'c0e0fc0c91dabdb86f68eed78e4a8f2b94fd1c2d' 2015-04-25 21:19:59 -07:00
tqchen
c0e0fc0c91 Squashed 'subtree/rabit/' changes from 82ca10a..27340f9
27340f9 final minor
e03eabc allow win32

git-subtree-dir: subtree/rabit
git-subtree-split: 27340f95e4
2015-04-25 21:19:58 -07:00
Tianqi Chen
6c83a94204 enable msvc win32 project 2015-04-25 21:14:07 -07:00
tqchen
5e63b5d469 Merge commit 'be1c530a0c92701841fa6a427d4f6a53d299cdeb' 2015-04-25 20:52:51 -07:00
tqchen
be1c530a0c Squashed 'subtree/rabit/' changes from c679671..82ca10a
82ca10a better handling at msvc
6601939 Merge pull request #12 from zjf/patch-2
df8f917 Update rabit-inl.h
c60b284 resize during tracker print

git-subtree-dir: subtree/rabit
git-subtree-split: 82ca10acb6
2015-04-25 20:52:51 -07:00
Tianqi Chen
afdebe8d8f fix platform dependent thing 2015-04-25 20:40:43 -07:00
Tianqi Chen
84515cd2a8 fix python windows installation problem, enable mingw compile, but seems mingw dll was not fast in loading 2015-04-25 15:30:42 -07:00
Tianqi Chen
4275434ec5 Merge pull request #260 from dmlc/colopt
Colopt
2015-04-25 10:15:33 -07:00
tqchen
5870b47d76 faster external memory 2015-04-25 10:14:56 -07:00
tqchen
b31d1c4ad9 check in colopt 2015-04-25 09:37:07 -07:00
Tianqi Chen
f28a7a0f8d Merge pull request #254 from lihang00/master
Python: add more params in sklearn wrapper.
2015-04-24 14:17:28 -07:00
HangLi
c6d2e16b61 remove eval_metric 2015-04-24 10:37:20 -07:00
HangLi
0058ebac9a add more params 2015-04-24 08:50:22 -07:00
Tianqi Chen
1d5b4e19a5 Merge pull request #258 from yzliao/master
remove print in Python function get_fscore()
2015-04-24 08:49:47 -07:00
Yizheng Liao
b5c8085638 remove print in Python get_fscore() 2015-04-23 23:40:10 -07:00
Yizheng Liao
84b82ab55f add flag variable in Python get_fscore() to control printing 2015-04-23 22:28:32 -07:00
Tianqi Chen
b94f7b0849 Merge pull request #257 from yzliao/master
Python: record evaluation results in train()
2015-04-23 21:51:09 -07:00
Yizheng Liao
1d8fc6280c correct format 2015-04-23 21:27:12 -07:00
Yizheng Liao
44d1043031 record training progress 2015-04-23 21:24:24 -07:00
HangLi
fcb833373b reorder parameters 2015-04-23 16:25:31 -07:00
Tianqi Chen
4aa1ea2d44 Merge pull request #252 from zjf/master
Fix a typo in comment
2015-04-23 14:37:26 -07:00
Tianqi Chen
dcb7ac81c1 Merge pull request #253 from tcfuji/master
Update README.md
2015-04-23 14:37:13 -07:00
HangLi
29e76c7ac0 add more params in sklearn wrapper. 2015-04-23 11:34:59 -07:00
Ted
7d3b51b873 Update README.md
Ensures OpenMP support
2015-04-23 14:08:39 -04:00
Jianfeng Zhu
11c45e5c60 Merge pull request #1 from zjf/zjf-patch-1
Update data.h
2015-04-23 14:22:10 +08:00
Jianfeng Zhu
f8ce8899bd Update data.h
Fix a minor typo, which may cause unnecessary confusion.
2015-04-23 14:21:05 +08:00
Tianqi Chen
e2c0ecbc92 Merge pull request #251 from zjf/patch-1
Update updater.h
2015-04-22 20:50:00 -07:00
Jianfeng Zhu
78907ca08d Update updater.h
Fix minor type
2015-04-23 11:44:47 +08:00
Tianqi Chen
d3af4e138f Merge pull request #249 from yzliao/master
add default value of gamma in parameter.md
2015-04-22 17:07:15 -07:00
Yizheng Liao
1b22ab7a7e add default value of gamma in parameter.md 2015-04-22 16:52:02 -07:00
Tianqi Chen
263d9bf84f Update README.md 2015-04-21 20:59:03 -07:00
tqchen
3e03c66e8a add note about distributed version 2015-04-20 12:37:23 -07:00
tqchen
0461231d3d more capacity for base 2015-04-20 16:21:55 +00:00
tqchen
dfec406afd half ram support 2015-04-19 21:29:13 -07:00
tqchen
5ad1555daf fix links to wiki 2015-04-19 14:23:47 -07:00
Tianqi Chen
a68928579b Update README.md 2015-04-19 14:21:12 -07:00
tqchen
50c1ce950f final chg 2015-04-19 14:07:39 -07:00
tqchen
315299aea8 add highlights 2015-04-19 14:07:08 -07:00
tqchen
6f14405b09 fix doc 2015-04-19 14:05:33 -07:00
tqchen
0220a22ca4 chg docs 2015-04-19 13:58:46 -07:00
tqchen
a1fdff0522 ok 2015-04-19 13:52:22 -07:00
tqchen
c6c868449c move documentation to repo 2015-04-19 13:48:19 -07:00
tqchen
5b042691b0 chg docs 2015-04-19 01:00:37 -07:00
Tianqi Chen
54a78b87dc Merge pull request #245 from dmlc/lite
Lite
2015-04-19 00:56:10 -07:00
tqchen
5123b07d73 add more docs 2015-04-19 00:55:11 -07:00
tqchen
44fd329b02 Squashed 'subtree/rabit/' changes from f52daf9..c679671
c679671 fix io style

git-subtree-dir: subtree/rabit
git-subtree-split: c67967161e
2015-04-19 00:23:02 -07:00
tqchen
ee112353cb Merge commit '44fd329b021bfd46a6b033a64467cda7d40310db' into lite 2015-04-19 00:23:02 -07:00
Tianqi Chen
18277086d9 fix windows warnings 2015-04-19 00:20:52 -07:00
tqchen
9527b55f35 fix makefile 2015-04-19 00:05:56 -07:00
tqchen
20da8bbe50 Squashed 'subtree/rabit/' changes from 7568f75..f52daf9
f52daf9 make timer cross platform

git-subtree-dir: subtree/rabit
git-subtree-split: f52daf9be1
2015-04-19 00:05:15 -07:00
tqchen
eb7cccffa4 Merge commit '20da8bbe504c0b81f6f3aff5b23f5bc3ee97d3f4' into lite 2015-04-19 00:05:15 -07:00
Bing Xu
47ee5e7c14 Update README.md 2015-04-18 14:46:00 -06:00
tqchen
5dfab4ba70 fast loader 2015-04-17 23:02:30 -07:00
tqchen
6d9cb3a2fa Merge branch 'lite' of ssh://github.com/tqchen/xgboost into lite
Conflicts:
	src/io/page_dmatrix-inl.hpp
2015-04-17 22:10:56 -07:00
tqchen
0a7d233c5d add 2015-04-17 22:09:26 -07:00
tqchen
788785f164 faster libsvm parser 2015-04-17 22:07:59 -07:00
tqchen
6bc5d6f0b4 Squashed 'subtree/rabit/' changes from 3bf8661..7568f75
7568f75 new io interface

git-subtree-dir: subtree/rabit
git-subtree-split: 7568f75f45
2015-04-17 21:07:33 -07:00
tqchen
c528c1e8e6 Merge commit '6bc5d6f0b44b957cc9f0d0b1fe5d420b0b59b8e2' into lite 2015-04-17 21:07:33 -07:00
tqchen
ddb7e538df OK 2015-04-16 17:03:18 -07:00
tqchen
22abf4e295 need more check 2015-04-16 12:34:39 -07:00
tqchen
a514340c96 current progress 2015-04-15 22:28:43 -07:00
tqchen
e8f6f3b541 some initial try of cachefiles 2015-04-15 15:15:23 -07:00
tqchen
3d8431fc5c simplify and parallelize data builder 2015-04-15 13:42:03 -07:00
Tianqi Chen
a596d11ed1 Merge pull request #241 from pommedeterresautee/master
Add experimental RF parameter documentation
2015-04-15 10:15:41 -07:00
El Potaeto
a49150a6d2 Redo readme modification 2015-04-15 18:49:52 +02:00
El Potaeto
de3f74f755 Merge remote-tracking branch 'dmlc/master' 2015-04-15 18:48:26 +02:00
El Potaeto
e4c8d9d2e1 clean 2015-04-15 18:47:31 +02:00
El Potaeto
511d74c631 clean 2015-04-15 18:46:28 +02:00
El Potaeto
ab8cf14fb9 cleaning 2015-04-15 18:44:06 +02:00
El Potaeto
0ae6d470c7 test 2015-04-15 18:36:53 +02:00
El Potaeto
925fa30316 Cancel readme modif 2015-04-15 18:32:04 +02:00
El Potaeto
2034b91b7d commit emtpy 2015-04-15 18:30:46 +02:00
pommedeterresautee
20dfcd7cec Add slides to readme + group documentation together 2015-04-14 00:48:11 +02:00
pommedeterresautee
12047056ae Update vignette 2015-04-14 00:39:51 +02:00
pommedeterresautee
4e1002a52c Experimental parameter 2015-04-14 00:30:55 +02:00
pommedeterresautee
aa0f612ac9 git ignore RProject files 2015-04-14 00:26:11 +02:00
tqchen
2b7c35870f Squashed 'subtree/rabit/' changes from 18f4d6c..3bf8661
3bf8661 add std before basic

git-subtree-dir: subtree/rabit
git-subtree-split: 3bf8661ec1
2015-04-13 13:44:41 -07:00
tqchen
6370b38c14 Merge commit '2b7c35870f7bf0ca7e28f53b322829007c91317e' 2015-04-13 13:44:41 -07:00
tqchen
24207d96fe new dmlc interface 2015-04-11 20:28:50 -07:00
tqchen
a30045c7cc Squashed 'subtree/rabit/' changes from 50a66b3..18f4d6c
18f4d6c remove rabit learn
bcfbe51 fix dmlc io
ad383b0 ok
3b8c04a Merge branch 'master' of ssh://github.com/dmlc/rabit
9dd97cc keepup with dmlc core
ef13aaf ch

git-subtree-dir: subtree/rabit
git-subtree-split: 18f4d6c0ba
2015-04-11 20:26:57 -07:00
tqchen
f55f8f023f Merge commit 'a30045c7cc54344e2084fb1fa3e01bfafc737188' 2015-04-11 20:26:57 -07:00
tqchen
bf7b750b86 add ignore 2015-04-11 09:25:19 -07:00
tqchen
91a7a5f2e2 add small boundary checking 2015-04-10 10:55:42 -07:00
Tianqi Chen
0ea28c35c4 Merge pull request #225 from chrissly31415/master
Fixing parsing of model dump text file in R
2015-04-09 09:53:38 -07:00
Tianqi Chen
7975dd03a9 Merge pull request #229 from nagadomi/fix_group_check_in_r
Fix length check in utils.R
2015-04-09 09:02:31 -07:00
tqchen
f4dbee5523 Squashed 'subtree/rabit/' changes from e08542c..50a66b3
50a66b3 fix empty engine

git-subtree-dir: subtree/rabit
git-subtree-split: 50a66b3855
2015-04-09 08:45:13 -07:00
tqchen
73ab391309 Merge commit 'f4dbee5523dc5816480f3c97cdb7192ceaec9dfc' 2015-04-09 08:45:13 -07:00
tqchen
c8c1dc6a3b xgboost update for dmlc changes 2015-04-08 17:42:54 -07:00
tqchen
3d11f56880 Squashed 'subtree/rabit/' changes from b15f6cd..e08542c
e08542c fix doc
e95c962 remove I prefix from interface, serializable now takes in pointer

git-subtree-dir: subtree/rabit
git-subtree-split: e08542c635
2015-04-08 17:39:45 -07:00
tqchen
9a6adb0f33 Merge commit '3d11f56880521c1d45504c965ae12886e9b72ace' 2015-04-08 17:39:45 -07:00
Tianqi Chen
23c273173f Merge pull request #230 from jseabold/python-install
Make the Python wrappers installable without path munging
2015-04-08 15:02:37 -07:00
Tong He
2c9631a254 Merge pull request #228 from khotilov/dep_reduction__mv2suggest
dependencies trim: moved external graphing packages to Suggests
2015-04-08 13:26:53 -07:00
Skipper Seabold
a0e07f16c4 Update demo scripts to use installed python library 2015-04-08 14:22:54 -05:00
Skipper Seabold
ceb62e9231 Update docs about python module install 2015-04-08 14:20:52 -05:00
Skipper Seabold
c972feb4b5 Make Python package installable. 2015-04-08 14:07:37 -05:00
nagadomi
87b4332cc1 Fix length check in utils.R 2015-04-09 02:25:47 +09:00
Vadim Khotilovich
76cef701ab moved the external graphing packages to Suggested in order to trim the dependencies 2015-04-07 18:02:29 -05:00
Vadim Khotilovich
aefd234da3 moved the external graphing packages to Suggested in order to trim the dependencies 2015-04-07 17:43:53 -05:00
Vadim Khotilovich
0405676734 Merge remote branch 'src/master' 2015-04-07 17:16:19 -05:00
Tianqi Chen
e91bacd378 Merge pull request #226 from white1033/master 2015-04-07 09:23:11 -07:00
white1033
b4545df0e3 *Fix Sklearn.grid_search error 2015-04-07 23:57:01 +08:00
chrissly31415
34cbbab84c fixing parsing of any numbers 2015-04-07 11:45:08 +02:00
chrissly31415
b39c16ea02 fixed parsing of negative reals, integers and scientific notation which
can occur in model dump
2015-04-07 10:57:54 +02:00
tqchen
01771c813d safe fix 2015-04-06 14:53:40 -07:00
tqchen
99f8dd280e push backward compatible fix 2015-04-06 14:50:21 -07:00
tqchen
36dcb061a8 larger boundary in edge case 2015-04-06 13:42:43 -07:00
tqchen
dc37023226 fix 2015-04-06 09:59:18 -07:00
tqchen
65abc26797 move distributed xgboost to wormhole 2015-04-06 09:56:45 -07:00
tqchen
421f5c6570 fix 2015-04-06 09:00:27 -07:00
tqchen
3cc48d6707 fix crash in error 2015-04-06 08:58:33 -07:00
tqchen
b6d85b9d9b fix label crash 2015-04-06 08:48:06 -07:00
tqchen
529a732737 add label error 2015-04-06 08:45:54 -07:00
tqchen
30e61084eb Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-04-05 20:42:27 -07:00
tqchen
0ffaeb8c64 add xgboost 2015-04-05 20:42:09 -07:00
Tianqi Chen
84957c3f84 update windows project for latest change 2015-04-05 20:13:20 -07:00
tqchen
8a3c0f1ae4 simple chg 2015-04-05 12:16:55 -07:00
tqchen
b8fd7c3c7c add instruction to build with s3 2015-04-05 12:10:59 -07:00
tqchen
fba9e5c714 quick fix 2015-04-05 12:01:19 -07:00
tqchen
5f902982f2 compile with dmlc 2015-04-05 11:26:06 -07:00
tqchen
89244b4aec Squashed 'subtree/rabit/' changes from 16975b4..b15f6cd
b15f6cd rabit unifires with dmlc
5634ec3 ok
2dd6c2f Merge branch 'master' of ssh://github.com/dmlc/rabit
38d7f99 checkin wormhole spliter
8acb96a Merge pull request #10 from ryanzz/master
911a1f0 fixed a mistake
732d8c3 inteface changing
684ea0a inteface changing
8cb4c02 add dmlc support
be2ff70 allow adapting wormhole

git-subtree-dir: subtree/rabit
git-subtree-split: b15f6cd2ac
2015-04-05 09:56:53 -07:00
tqchen
9b7907eda3 Merge commit '89244b4aec1f229b9ba1378389d4dea697389666' 2015-04-05 09:56:53 -07:00
Tianqi Chen
e626b62daa Merge pull request #220 from white1033/master
*Fix XGBClassifier super()
2015-04-05 09:05:08 -07:00
white1033
18cb8d7de2 fix indent warning by flake8 2015-04-05 23:22:40 +08:00
white1033
402e832ce5 *Fix XGBClassifier super() 2015-04-05 21:15:09 +08:00
Vadim Khotilovich
31b0e53cd4 make it possible to use a list of pre-defined CV folds in xgb.cv 2015-04-03 13:24:04 -05:00
Vadim Khotilovich
c03b42054f Merge remote branch 'src/master' 2015-04-03 13:18:40 -05:00
Vadim Khotilovich
271e8202a7 force xgb.cv to return numeric performance values instead of character; update its docs 2015-04-03 12:20:34 -05:00
Vadim Khotilovich
b04920d8e7 update documentation for xgb.cv 2015-04-03 11:14:09 -05:00
Tianqi Chen
93d3f4fe61 Merge pull request #217 from nerdcha/master
Bugfix for multiclass sklearn wrapper
2015-04-02 21:14:21 -07:00
Jamie Hall
d17cdd639f bugfix 2015-04-02 20:33:07 -07:00
Vadim Khotilovich
611d69c771 fix some wording 2015-04-02 19:59:06 -05:00
Vadim Khotilovich
b8711226e2 added an option for stratified CV to xgb.cv 2015-04-02 19:48:23 -05:00
Tianqi Chen
9b0dee986f Merge pull request #212 from zygmuntz/master
Early stopping for Python wrapper
2015-04-02 17:31:44 -07:00
Tianqi Chen
e9c95645a3 Merge pull request #215 from nerdcha/master
Scikit-Learn Wrapper For XGBoost
2015-04-02 12:25:55 -07:00
Zygmunt Zając
d7f9499f88 early_stopping_rounds for train() in Python wrapper 🔥 2015-04-02 19:43:30 +02:00
Jamie Hall
a1a427af37 Fix some stuff 2015-04-02 00:05:14 -07:00
Jamie Hall
136e902fb2 Initial commit 2015-04-01 23:29:05 -07:00
tqchen
8d1f4a40a5 Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-03-30 16:06:18 -07:00
tqchen
49e641012f add objective 2015-03-30 16:05:51 -07:00
Zygmunt Zając
39093bc432 early stopping for Python wrapper 2015-03-30 19:59:09 +02:00
Zygmunt Zając
7994858697 early stopping for Python wrapper 2015-03-30 19:58:25 +02:00
Zygmunt Zając
f9e157011f early stopping for Python wrapper 2015-03-30 19:56:03 +02:00
unknown
431277d5ca fix multi cv pred 2015-03-29 00:02:29 -07:00
unknown
37567e440c optim pred in cv 2015-03-28 23:41:19 -07:00
unknown
930497e271 fix matrix form prediction 2015-03-28 23:03:16 -07:00
El Potaeto
be6bd3859d Add Random Forest parameter (num_parallel_tree) in function doc + example in Vignette. 2015-03-29 01:52:26 +01:00
Tianqi Chen
b04591cbfc Update README.md 2015-03-28 08:58:30 -07:00
tqchen
68c2aaa7fe Squashed 'subtree/rabit/' changes from eb1f4a4..16975b4
16975b4 try pass on tokens during application submission

git-subtree-dir: subtree/rabit
git-subtree-split: 16975b447c
2015-03-27 11:09:38 -07:00
tqchen
135d461c40 Merge commit '68c2aaa7fe8c1f4688cef2ace67642e85fd1c9d2' 2015-03-27 11:09:38 -07:00
tqchen
0c349d6101 Squashed 'subtree/rabit/' changes from 59e63bc..eb1f4a4
eb1f4a4 change auto to ip

git-subtree-dir: subtree/rabit
git-subtree-split: eb1f4a4003
2015-03-26 23:33:41 -07:00
tqchen
38911fe2b2 Merge commit '0c349d6101652836f2ec23e48f94b4137aac6108' 2015-03-26 23:33:41 -07:00
tqchen
4eae8e8676 allow xgb.load re-use raw information if necessary 2015-03-26 16:54:29 -07:00
tqchen
98618646f6 bugfix booster.check 2015-03-26 16:43:01 -07:00
tqchen
23e46b7fa5 add max_delta_step 2015-03-26 09:47:16 -07:00
tqchen
149b43a0a8 Merge branch 'master' of ssh://github.com/dmlc/xgboost 2015-03-25 21:08:29 -07:00
tqchen
a84d6c55b3 more detailed explaination on windows build 2015-03-25 21:08:21 -07:00
Tong He
db0b06d19c add another solution to os x 2015-03-25 17:14:14 -07:00
hetong007
047c4b20de remove additional files 2015-03-25 16:06:51 -07:00
tqchen
08fb205102 cap second order gradient 2015-03-25 12:08:53 -07:00
tqchen
53c9a7b66b fix quantile for edge case, make logloss evaluation capped for extreme values 2015-03-24 23:52:42 -07:00
tqchen
d53e642b5d add debuglog for quantile 2015-03-23 21:17:50 -07:00
Tianqi Chen
da3a376384 Merge pull request #203 from pommedeterresautee/master
update links dmlc
2015-03-22 09:34:09 -07:00
El Potaeto
7d0ac3a3dd update links dmlc 2015-03-22 16:41:05 +01:00
tqchen
70045c41f9 change links 2015-03-21 23:12:55 -07:00
Tong He
03911cf748 Update README.md 2015-03-21 22:34:19 -07:00
Tianqi Chen
1a9a3a2fd0 Update README.md 2015-03-21 22:26:59 -07:00
Tianqi Chen
87741bded6 Update README.md 2015-03-21 22:26:24 -07:00
Tianqi Chen
25266796e9 Merge pull request #201 from pommedeterresautee/master
add video tuto to the README
2015-03-21 22:23:52 -07:00
tqchen
9ccbeaa8f0 Merge commit '75bf97b57539e5572e7ae8eba72bac6562c63c07'
Conflicts:
	subtree/rabit/rabit-learn/io/line_split-inl.h
	subtree/rabit/yarn/build.sh
2015-03-21 00:48:34 -07:00
tqchen
75bf97b575 Squashed 'subtree/rabit/' changes from 091634b..59e63bc
59e63bc minor
6233050 ok
14477f9 add namenode
75a6d34 add libhdfs opts
e3c76bf minmum fix
8b3c435 chg
2035799 test code
7751b2b add debug
7690313 ok
bd346b4 ok
faba1dc add testload
6f7783e add testload
e5f0340 ok
3ed9ec8 chg
e552ac4 ask for more ram in am
b2505e3 only stop nm when sucess
bc696c9 add queue info
f3e867e add option queue
5dc843c refactor fileio
cd9c81b quick fix
1e23af2 add virtual destructor to iseekstream
f165ffb fix hdfs
8cc6508 allow demo to pass in env
fad4d69 ok
0fd6197 fix more
7423837 fix more
d25de54 add temporal solution, run_yarn_prog.py
e5a9e31 final attempt
ed3bee8 add command back
0774000 add hdfs to resource
9b66e7e fix hadoop
6812f14 ok
08e1c16 change hadoop prefix back to hadoop home
d6b6828 Update build.sh
146e069 bugfix: logical boundary for ring buffer
19cb685 ok
4cf3c13 Merge branch 'master' of ssh://github.com/tqchen/rabit
20daddb add tracker
c57dad8 add ringbased passing and batch schedule
295d8a1 update
994cb02 add sge
014c866 OK

git-subtree-dir: subtree/rabit
git-subtree-split: 59e63bc135
2015-03-21 00:44:31 -07:00
Tong He
5648bec8a3 Update utils.R 2015-03-20 22:41:47 -07:00
hetong007
7ced224722 change name 2015-03-20 18:46:52 -07:00
Tong He
2e71d2dfe4 Update readme.md 2015-03-20 16:05:36 -07:00
hetong007
4bcc73f0c9 add kaggle otto folder 2015-03-20 13:34:20 -07:00
Tong He
f6722ba628 Update utils.R 2015-03-20 11:06:01 -07:00
El Potaeto
3777ad8f17 Merge remote-tracking branch 'upstream/master' 2015-03-20 10:16:48 +01:00
El Potaeto
2b24697d79 add tuto to the README 2015-03-20 10:14:38 +01:00
tqchen
360cc7118d fix cxx11 2015-03-19 11:53:55 -07:00
tqchen
e1538ae615 add new evaluation metric mlogloss for multi-class classification logloss 2015-03-19 11:34:38 -07:00
Tong He
8025b338a8 Merge pull request #199 from pommedeterresautee/master
Cross validation documentation improvement
2015-03-18 11:14:36 -07:00
pommedeterresautee
4094039ce5 README 2015-03-17 23:32:52 +01:00
pommedeterresautee
33205d1fbd Cross validation documentation improvement 2015-03-17 23:18:00 +01:00
Tong He
adfa023822 Merge pull request #198 from pommedeterresautee/master
Add new nrow function for xgb.DMatrix + small function doc changes
2015-03-17 12:29:00 -07:00
Tong He
a146f0c5e1 Update utils.R 2015-03-16 23:23:22 -07:00
Tong He
1e001f7cf3 add length check 2015-03-16 23:20:31 -07:00
pommedeterresautee
240c314ac0 doc 2015-03-16 00:12:23 +01:00
pommedeterresautee
9d1d76532d documentation 2015-03-16 00:10:18 +01:00
pommedeterresautee
6ca76fe784 doc 2015-03-15 23:59:28 +01:00
pommedeterresautee
81caba5dce new nrow function for xgb.DMatrix 2015-03-15 23:52:00 +01:00
pommedeterresautee
cdfa78a3b9 small changes in doc 2015-03-15 23:51:26 +01:00
tqchen
8386c2b7fa check r 2015-03-13 23:49:56 -07:00
Tianqi Chen
2159d18f0b Update param.h 2015-03-13 23:23:23 -07:00
Tianqi Chen
90ade3bb84 Merge pull request #193 from pommedeterresautee/master
Vignette text (very biiiiig change)
2015-03-13 14:50:49 -07:00
El Potaeto
93a019d174 code simplification 2015-03-12 23:44:08 +01:00
El Potaeto
09091884be Merge remote-tracking branch 'upstream/master' 2015-03-11 22:14:35 +01:00
tqchen
e52de85e59 Merge branch 'master' of ssh://github.com/tqchen/xgboost 2015-03-11 11:22:56 -07:00
tqchen
12528c535a fix 2015-03-11 11:22:51 -07:00
tqchen
03f34824b4 some potential fix 2015-03-11 09:43:42 -07:00
tqchen
8437e43afc pass solaris compile 2015-03-11 09:15:34 -07:00
tqchen
52fe528615 fix rpack 2015-03-11 08:53:57 -07:00
Tong He
8f24f3cd5a Update speedtest.R 2015-03-10 22:55:48 -07:00
Tianqi Chen
d5303af068 fix vs warnings 2015-03-09 22:37:08 -07:00
tqchen
13a319ca01 Squashed 'subtree/rabit/' changes from d558f6f..091634b
091634b fix

git-subtree-dir: subtree/rabit
git-subtree-split: 091634b259
2015-03-09 14:58:23 -07:00
tqchen
5c389ed89a Merge commit '13a319ca01e6fadd0ec7592cff8e7b545af0994e' 2015-03-09 14:58:23 -07:00
tqchen
deceec3e10 update 2015-03-09 14:57:49 -07:00
tqchen
8f7e9abf89 Merge commit '4c060df2f17405dc26dc65a77e412d5c2a23525a'
Conflicts:
	subtree/rabit/tracker/rabit_yarn.py
2015-03-09 14:45:23 -07:00
tqchen
4c060df2f1 Squashed 'subtree/rabit/' changes from 28ca7be..d558f6f
d558f6f redefine distributed means
c8efc01 more complicated yarn script

git-subtree-dir: subtree/rabit
git-subtree-split: d558f6f550
2015-03-09 14:44:42 -07:00
tqchen
a8d5af39fd move stream to rabit part, support rabit on yarn 2015-03-09 14:43:46 -07:00
tqchen
57b5d7873f Squashed 'subtree/rabit/' changes from d4ec037..28ca7be
28ca7be add linear readme
ca4b20f add linear readme
1133628 add linear readme
6a11676 update docs
a607047 Update build.sh
2c1cfd8 complete yarn
4f28e32 change formater
2fbda81 fix stdin input
3258bcf checkin yarn master
67ebf81 allow setup from env variables
9b6bf57 fix hdfs
395d5c2 add make system
88ce767 refactor io, initial hdfs file access need test
19be870 chgs
a1bd3c6 Merge branch 'master' of ssh://github.com/tqchen/rabit
1a573f9 introduce input split
29476f1 fix timer issue

git-subtree-dir: subtree/rabit
git-subtree-split: 28ca7becbd
2015-03-09 13:28:38 -07:00
tqchen
9f7c6fe271 Merge commit '57b5d7873f4f0953357e9d98e9c60cff8373d7ec' 2015-03-09 13:28:38 -07:00
El Potaeto
21a4a32655 Vignette text 2015-03-08 21:57:31 +01:00
Tong He
66cf88f7b0 Merge pull request #192 from pommedeterresautee/master
Vignette improvement
2015-03-08 10:08:33 -07:00
tqchen
99ef34ca8c Merge branch 'master' of ssh://github.com/tqchen/xgboost 2015-03-08 09:55:40 -07:00
tqchen
e79840e620 fix wrapper checkNAN 2015-03-08 09:52:59 -07:00
El Potaeto
09e466764e Vignette text 2015-03-08 00:38:22 +01:00
El Potaeto
05dbc40186 space 2015-03-08 00:03:40 +01:00
El Potaeto
5a59c0b26c df spell 2015-03-08 00:02:14 +01:00
Tianqi Chen
2ec27679eb Merge pull request #190 from pommedeterresautee/master
trademark RF
2015-03-07 08:58:50 -08:00
tqchen
d202d8b977 more robust config parser 2015-03-07 08:52:56 -08:00
tqchen
bae1a08c9b remove mock from default build 2015-03-06 21:02:22 -08:00
El Potaeto
5bc9642d31 trademark RF 2015-03-04 12:09:50 +01:00
tqchen
39cb9d2c5e fix nan 2015-03-03 22:33:03 -08:00
hetong
841d076f20 change version of the package 2015-03-03 18:14:25 -08:00
tqchen
e50fa9e78f fix solaris 2015-03-03 13:16:20 -08:00
tqchen
ef2de29f06 Squashed 'subtree/rabit/' changes from 4db0a62..d4ec037
d4ec037 fix rabit
6612fcf Merge branch 'master' of ssh://github.com/tqchen/rabit
d29892c add mock option statis
4fa054e new tracker
75c647c update tracker for host IP
e4ce8ef add hadoop linear example
76ecb4a add hadoop linear example
2e1c4c9 add hadoop linear example

git-subtree-dir: subtree/rabit
git-subtree-split: d4ec037f2e
2015-03-03 13:13:21 -08:00
tqchen
3897b7bf99 Merge commit 'ef2de29f068c0b22a4fb85ca556b7b77950073d6' 2015-03-03 13:13:21 -08:00
tqchen
9fd8612700 fix cranchecks 2015-03-03 12:37:29 -08:00
hetong
ee6e8279eb add vcd back 2015-03-03 00:25:30 -08:00
hetong
41b080e35f To submit to CRAN we cannot use more than 2 threads in our examples/vignettes 2015-03-03 00:21:24 -08:00
Tong He
87ec48c1d3 change order of sentences
Dear Prof. Ripley said that "The Description field should not start with the package name, 'This package' or similar."
2015-03-02 22:45:49 -08:00
Tong He
aa60c44b25 Merge pull request #186 from pommedeterresautee/master
Presentation (CSS) : more space + more structure
2015-03-02 09:55:23 -08:00
El Potaeto
0c77726b55 CSS: Add slight line after Header 1 2015-03-02 14:47:00 +01:00
El Potaeto
a6a707f23c Add ref. 2015-03-02 14:37:25 +01:00
El Potaeto
4ee43f2167 CSS improvement, more space, change in style titles 2015-03-02 14:36:19 +01:00
Tong He
c62583bb0f Update discoverYourData.Rmd 2015-03-01 22:15:47 -08:00
Tong He
48deb49ba1 possible polishments 2015-03-01 22:02:23 -08:00
Tong He
57972ef2c2 Update xgboost.Rnw 2015-03-01 21:32:59 -08:00
tqchen
4210f9cf51 add conf 2015-03-01 20:41:26 -08:00
Tong He
576b8acfae Update xgboostPresentation.Rmd 2015-03-01 18:30:49 -08:00
Tong He
b8c0d8ba72 Merge pull request #185 from pommedeterresautee/master
Vignette improvement: more structure, more serious, less spell/grammar issues, better organization
2015-03-01 18:28:58 -08:00
El Potaeto
de6bedc7cb Vignette text 2015-03-01 21:35:36 +01:00
El Potaeto
711fb128cd Vignette text 2015-03-01 21:31:42 +01:00
El Potaeto
d88cf20c23 Vignette text 2015-03-01 21:25:14 +01:00
El Potaeto
a749cf3133 Vignette text 2015-03-01 21:22:26 +01:00
pommedeterresautee
46082a54c9 Vignette text 2015-03-01 13:01:42 +01:00
pommedeterresautee
8e52c4b45a Fix Vignette bug! 2015-03-01 12:13:38 +01:00
pommedeterresautee
4559477d63 text vignette 2015-03-01 11:01:03 +01:00
pommedeterresautee
2986d913ed Vignette text 2015-03-01 10:20:41 +01:00
hetong
8f0e99c3ce import vcd to eliminate note 2015-02-28 10:11:44 -08:00
Tong He
a96ac937f8 Merge pull request #184 from pommedeterresautee/master
fix warning
2015-02-26 16:01:58 -08:00
pommedeterresautee
8abd9c747a fix warning 2015-02-27 00:49:20 +01:00
Tianqi Chen
9784c471d5 Update README.md 2015-02-25 10:05:50 -08:00
Tianqi Chen
2c69a17e77 Update README.md 2015-02-25 10:00:52 -08:00
Tong He
8e93b18555 Merge pull request #182 from pommedeterresautee/master
Memory optimization in co occurence comp feature importance (use sparse Matrix if required) + Vignette text (spell, grammar...) + CSS
2015-02-23 13:19:34 -08:00
El Potaeto
56068b5453 text vignette 2015-02-22 00:17:37 +01:00
El Potaeto
56e9bff11f Vignette txt 2015-02-21 23:49:41 +01:00
El Potaeto
48390bdd6a text 2015-02-19 19:26:39 +01:00
El Potaeto
56877338b7 memory optimization 2015-02-19 13:48:39 +01:00
Tong He
dce522d7a1 Merge pull request #179 from pommedeterresautee/master
Generalize co-occurence count to not categorical feature only + Perf + Vignette + CSS + Function documentation
2015-02-18 16:55:40 -08:00
El Potaeto
815789bed6 fix 2015-02-19 00:16:50 +01:00
El Potaeto
d982f2746c small fixes 2015-02-18 19:41:13 +01:00
El Potaeto
83ddbbf03b splell 2015-02-18 17:14:08 +01:00
El Potaeto
8523fb9f49 avoid error message 2015-02-18 13:44:21 +01:00
El Potaeto
dabb0fd4c0 Merge remote-tracking branch 'upstream/master' 2015-02-18 13:25:15 +01:00
El Potaeto
f57f0f2543 Documentation feature importance 2015-02-18 13:19:39 +01:00
El Potaeto
8fd546ab3c vignette text 2015-02-18 13:13:27 +01:00
El Potaeto
1cfa810edb refix 2015-02-17 23:37:56 +01:00
El Potaeto
fe4f73920b Merge remote-tracking branch 'origin/master'
Conflicts:
	R-package/vignettes/discoverYourData.Rmd
	R-package/vignettes/vignette.css
2015-02-17 23:35:52 +01:00
El Potaeto
412a6e1085 Add comments 2015-02-17 23:30:36 +01:00
El Potaeto
08493c2b3d missing feature management 2015-02-17 23:27:02 +01:00
El Potaeto
d4731e7b29 vignette text 2015-02-17 23:06:09 +01:00
El Potaeto
2ea6fd9931 better CSS 2015-02-17 23:01:48 +01:00
El Potaeto
e2b2c21aef better co occurence function 2015-02-17 22:39:38 +01:00
pommedeterresautee
2e391ed0ee text refactor 2015-02-16 22:43:12 +01:00
pommedeterresautee
8e3c25ed33 css improvement 2015-02-16 22:35:01 +01:00
Tianqi Chen
15562126a6 Merge pull request #178 from aldanor/master
[python] Fixed the dll import for relative paths + various cleanup.
2015-02-16 09:51:40 -08:00
Ivan Smirnov
8660ea91b5 Fixed the dll import for relative paths + various cleanup.
- DLL import now works when __file__ is a relative path
- Various PEP8 and whitespace fixes + whitespace cleanup
- Docstring fixes (conform to numpydoc)
- Added __all__ to the module
- Fixed mutable default values
- Removed print statements
- py2/py3-compatible string-type checks
- Replace asserts with proper exceptions
- Make classes new-style (derive from object)
2015-02-16 16:03:47 +00:00
Tong He
1b92d9eadf Merge pull request #177 from pommedeterresautee/master
New co occurence computation (for importance feature function)
2015-02-15 16:48:33 -08:00
El Potaeto
f0eaac2174 Bug + documentation 2015-02-15 17:46:12 +01:00
El Potaeto
f84cc0843f fixed bug 2015-02-15 17:30:39 +01:00
El Potaeto
def2674dd1 Add new co-occurence computation capacity to importance feature function + related documentation 2015-02-15 17:15:47 +01:00
El Potaeto
d75194303b CSS improvement 2015-02-15 10:26:32 +01:00
Tong He
fe7651fe53 Merge pull request #175 from pommedeterresautee/master
markdown Vignette can be compiled as package Vignette (use devtools) + improve Vignette text
2015-02-14 14:38:45 -08:00
hetong007
3adfe4eeda not build the vignette 2015-02-13 13:13:29 -08:00
El Potaeto
3da261b6e7 add linear boosting part 2015-02-13 18:49:53 +01:00
Tianqi Chen
a718a43d92 Update mushroom.hadoop.conf 2015-02-13 09:04:05 -08:00
El Potaeto
9a4bf40e5e clean temp 2015-02-13 13:34:24 +01:00
El Potaeto
8a7d803e52 justified text in CSS 2015-02-13 13:28:04 +01:00
pommedeterresautee
ae9f7e9307 vignette text 2015-02-12 22:44:57 +01:00
pommedeterresautee
276b68b984 Vignette text 2015-02-12 22:22:00 +01:00
El Potaeto
7421f35136 vignette text 2015-02-12 20:05:38 +01:00
El Potaeto
ba36c495be text vignette 2015-02-12 17:36:10 +01:00
El Potaeto
7f71cc12f4 add bibliography 2015-02-12 17:19:11 +01:00
El Potaeto
8a8eb33114 fix temp file created by PDF 2015-02-12 15:47:53 +01:00
El Potaeto
df63c86afa git ignore update -> exclude generated vignette 2015-02-12 14:05:19 +01:00
El Potaeto
09a6522704 Vignette text 2015-02-12 13:59:45 +01:00
El Potaeto
234cf49e35 fix some CSS 2015-02-12 13:59:23 +01:00
El Potaeto
7bb2926414 add introduction paragraph from PDF file 2015-02-12 10:19:42 +01:00
El Potaeto
16ffd7c9b2 Comment wording 2015-02-12 09:56:27 +01:00
El Potaeto
f1f346713a Merge remote-tracking branch 'upstream/master' 2015-02-12 09:51:42 +01:00
Tianqi Chen
f8a314e2e4 Merge pull request #176 from tqchen/unity
pull rabit updates
2015-02-11 20:37:54 -08:00
tqchen
13776a006a Squashed 'subtree/rabit/' changes from 1bb8fe9..4db0a62
4db0a62 bugfix of lazy prepare
87017bd license
dc703e1 license
c171440 change license to bsd
7db2070 Update README.md
581fe06 add mocktest
d2f252f ok
4a5b9e5 add all
12ee049 init version of lbfgs
37a2837 complete lbfgs solver
6ade7cb complete lbfgs

git-subtree-dir: subtree/rabit
git-subtree-split: 4db0a62a06
2015-02-11 20:33:35 -08:00
tqchen
e923bdb12f Merge commit '13776a006a4e572720ec4c5b029b54771cf2b35c' into unity 2015-02-11 20:33:35 -08:00
pommedeterresautee
97cb8bf637 refactor vignette 2015-02-12 00:06:13 +01:00
tqchen
c40afa2023 fix sklearner 2015-02-11 11:37:14 -08:00
tqchen
c639efc71b Merge branch 'master' into unity 2015-02-11 10:58:19 -08:00
tqchen
2ec113b1be Merge branch 'unity'
Conflicts:
	R-package/R/predict.xgb.Booster.R
2015-02-11 10:58:09 -08:00
El Potaeto
adf8b6553d Vignettes 2015-02-11 18:01:36 +01:00
El Potaeto
d70f52d4b1 Vignette text 2015-02-11 15:25:25 +01:00
El Potaeto
e457b5ea58 Simplified my name :-) 2015-02-11 15:25:12 +01:00
El Potaeto
9d11936790 improve function documentation.
Switch xgboost detailed parameters with xgb.tain function.
2015-02-11 10:12:18 +01:00
tqchen
a16cbedfab try fix memleak when test data have more features than training 2015-02-10 21:49:29 -08:00
Tong He
292f4f0e0d Merge pull request #171 from pommedeterresautee/master
Vignette (1 updated, 1 new)
2015-02-10 16:19:54 -08:00
pommedeterresautee
dc9e4905e4 Vignette text 2015-02-10 22:48:16 +01:00
El Potaeto
d7ba5c1511 text vignette 2015-02-10 19:46:39 +01:00
El Potaeto
cefd55ef00 Vignettes improvement 2015-02-10 17:09:21 +01:00
El Potaeto
c0d8ae3781 text change 2015-02-10 13:59:13 +01:00
El Potaeto
423c3e6a8d improved vignette text 2015-02-10 13:54:30 +01:00
tqchen
a30635e0b4 Merge branch 'master' of ssh://github.com/tqchen/xgboost 2015-02-09 21:08:07 -08:00
tqchen
e889da4cc1 new Rpack 2015-02-09 21:07:57 -08:00
hetong007
7f3dc7cf7e fix warnings 2015-02-09 18:38:23 -08:00
hetong007
25f508e43e update doc, resolve warnings 2015-02-09 17:48:52 -08:00
hetong007
47b5cf5148 fix save.raw 2015-02-09 17:35:50 -08:00
hetong007
4c25600d2a fix segfault and add two function for handle and booster 2015-02-09 17:28:48 -08:00
hetong007
0aef62dabc fix with new predict 2015-02-09 16:25:00 -08:00
hetong007
f7c838ffaa fix bugs 2015-02-09 16:16:11 -08:00
hetong007
5b611c355e add handle and raw structure to xgb.Booster 2015-02-09 15:51:24 -08:00
hetong007
ea5860d574 fix save.raw doc 2015-02-09 13:43:32 -08:00
Tong He
8c16491b42 Update xgb.save.raw.R 2015-02-09 13:31:21 -08:00
Tong He
ac3791bf74 Merge pull request #169 from pommedeterresautee/master
Fix some warnings in Cran check
2015-02-09 13:16:15 -08:00
pommedeterresautee
eecfd015fa Update CK.means version 2015-02-09 21:37:31 +01:00
pommedeterresautee
f4b454d6dd fix some warning in Cran check 2015-02-09 21:34:53 +01:00
Tianqi Chen
a3cf30592f Merge pull request #168 from pommedeterresautee/master
xgboost simplified documentation + dump function performance optimization (for big model)
2015-02-09 09:05:57 -08:00
El Potaeto
3971323203 fix bug 2015-02-09 18:01:14 +01:00
El Potaeto
0922883250 Optimization in dump function (replaced some regular R function by data.table) 2015-02-09 17:20:21 +01:00
El Potaeto
a45497e6f3 add web address 2015-02-08 22:46:59 +01:00
El Potaeto
76e24fdd36 documentation simplification 2015-02-08 22:46:29 +01:00
El Potaeto
29b5312428 remove not required dependency 2015-02-08 00:02:53 +01:00
El Potaeto
9d89441e38 small doc fix 2015-02-07 23:58:09 +01:00
El Potaeto
12b0e8e6d5 small doc fix 2015-02-07 23:57:48 +01:00
El Potaeto
75f205b0b1 fix documentation 2015-02-07 23:53:55 +01:00
El Potaeto
85739c537d new doc 2015-02-07 23:40:49 +01:00
El Potaeto
85186a2e55 remove buggy feature 2015-02-06 11:44:09 +01:00
tqchen
8b4acef662 remove sync from wrapper.h 2015-02-05 21:03:06 -08:00
El Potaeto
a82a942cd6 add importance feature sign 2015-02-05 17:25:37 +01:00
El Potaeto
68290546ca simplidied included column computation 2015-02-05 09:53:21 +01:00
El Potaeto
b7526671ba wording 2015-02-05 00:03:39 +01:00
El Potaeto
92652bffa1 wording 2015-02-05 00:01:13 +01:00
El Potaeto
9f5889f1e3 new included feature in dt.tree function 2015-02-04 23:59:53 +01:00
tqchen
b34a56b1f9 fix for ulong 2015-02-04 11:18:56 -08:00
Tong He
90c698ba13 Merge pull request #162 from pommedeterresautee/patch-1
Spell
2015-02-02 13:09:59 -08:00
Michaël Benesty
5d135858f7 Spell 2015-02-02 13:21:13 +01:00
tqchen
1d21ff87ff add saveload to raw 2015-02-01 21:19:24 -08:00
tqchen
dc3003cefd add saveload to raw 2015-02-01 21:17:37 -08:00
Tong He
6e91846c55 Merge pull request #155 from pommedeterresautee/master
fix mermaid + change in description + new plot importance feature function + fix bug in CV function + add 1 Vignette
2015-02-01 14:12:43 -08:00
El Potaeto
451944c52b CSS 2015-02-01 16:13:18 +01:00
El Potaeto
b31cbdb0a4 modif CSS 2015-02-01 16:13:13 +01:00
pommedeterresautee
a17e29b130 Fix bug in Cross Validation when showsd = FALSE 2015-02-01 14:08:48 +01:00
pommedeterresautee
9f5929497a version stringr 2015-02-01 13:09:27 +01:00
pommedeterresautee
f35950dc46 small change in package version 2015-02-01 13:02:33 +01:00
tqchen
02e98e0534 chg back to g++ 2015-01-30 21:47:49 -08:00
tqchen
3791ae5cf0 Squashed 'subtree/rabit/' changes from fb13cab..1bb8fe9
1bb8fe9 chg makefile

git-subtree-dir: subtree/rabit
git-subtree-split: 1bb8fe9615
2015-01-30 16:50:27 -08:00
tqchen
8b2dbbb782 Merge commit '3791ae5cf0a03aa64c763692cb4a5865816f37b6' 2015-01-30 16:50:27 -08:00
tqchen
b32d4faa82 quick fix seed 2015-01-30 16:50:10 -08:00
tqchen
9725cf2aeb Squashed 'subtree/rabit/' changes from 4ebe657..fb13cab
fb13cab change makefile
1479e37 fixed small bug in mpi submission script
0ca7a63 Update README.md
5ef4830 ok
93a1338 chg note

git-subtree-dir: subtree/rabit
git-subtree-split: fb13cab216
2015-01-30 16:41:06 -08:00
tqchen
25957bb1d4 Merge commit '9725cf2aeb26d5366ab659a59334b601b980f90b' 2015-01-30 16:41:06 -08:00
tqchen
42a4da91b5 chges 2015-01-30 16:40:58 -08:00
Tong He
964c668d44 Update DESCRIPTION 2015-01-29 16:20:13 -08:00
Tong He
f3b2c74153 Update README.md 2015-01-29 15:30:46 -08:00
Tong He
d788bf9aeb Update DESCRIPTION 2015-01-29 15:27:29 -08:00
Tong He
4d79ed9bb1 Update runall.R 2015-01-29 13:30:47 -08:00
El Potaeto
7ec17038f0 improve text of the Vignette 2015-01-29 10:30:50 +01:00
El Potaeto
f71aa2874c Vignette, 1st version 2015-01-28 21:43:18 +01:00
El Potaeto
170dcc49be doc 2015-01-28 21:42:58 +01:00
El Potaeto
e35a9f4822 Merge remote-tracking branch 'upstream/master' 2015-01-28 10:13:58 +01:00
tqchen
16db3ce620 quick fix 2015-01-27 16:31:53 -08:00
tqchen
3e0fba392d fix the integer overflow 2015-01-27 16:29:52 -08:00
pommedeterresautee
d6ef74386d ... 2015-01-27 22:36:35 +01:00
pommedeterresautee
5687af9774 fix error message during check 2015-01-27 22:29:29 +01:00
pommedeterresautee
e06c1da842 new plot feature importance function 2015-01-27 22:26:57 +01:00
tqchen
deb4983273 ok 2015-01-26 10:40:04 -08:00
tqchen
a264bc3969 ok 2015-01-26 10:30:12 -08:00
tqchen
e72174f0f8 add readme 2015-01-26 10:29:34 -08:00
tqchen
1f6b8eb344 Merge branch 'master' of ssh://github.com/tqchen/xgboost
Conflicts:
	.gitignore
2015-01-26 10:28:20 -08:00
tqchen
c34367b207 add msd 2015-01-26 10:27:44 -08:00
Tianqi Chen
97e058dbd7 Update README.md 2015-01-26 09:04:55 -08:00
Tianqi Chen
4266827105 Update README.md 2015-01-26 09:04:34 -08:00
El Potaeto
15dee73795 change in Description 2015-01-26 00:00:14 +01:00
hetong007
5188bad873 fix cv attr 2015-01-25 14:16:46 -08:00
El Potaeto
5e94126963 fix mermaid 2015-01-25 21:07:06 +01:00
El Potaeto
52a2b652d3 Documentation: no need to save model in txt... 2015-01-25 20:16:56 +01:00
hetong
f75387f701 update document 2015-01-25 10:37:11 -08:00
hetong
33101d5cad edit document 2015-01-25 10:31:48 -08:00
Tong He
8971f0ff50 Update xgboost.R 2015-01-25 10:21:24 -08:00
tqchen
f848844310 better warning at multiclass, fix cran check 2015-01-25 10:05:47 -08:00
Tong He
da9f0989c6 Merge pull request #152 from pommedeterresautee/master
Fix global variable message (Cran Checks)
2015-01-22 10:26:15 -08:00
El Potaeto
d188c997f0 add RStudio parameters to exclusion 2015-01-21 23:56:27 +01:00
pommedeterresautee
7f1aff7858 forget one variable 2015-01-21 22:07:30 +01:00
El Potaeto
f1d9fe8153 fix a bug introduced in previous commit 2015-01-21 13:31:17 +01:00
El Potaeto
e475b7d84e Avoid some Cran check error messages 2015-01-21 13:26:34 +01:00
hetong
34e2fbd2c4 fix some issues from the cran check 2015-01-20 21:29:51 -08:00
tqchen
417ac4a631 rm socket from source 2015-01-20 17:15:54 -08:00
hetong007
42110f3d70 documentation update 2015-01-20 16:24:01 -08:00
hetong007
d87cb24793 documentation update 2015-01-20 16:21:13 -08:00
hetong007
6901e90730 resolving not-CRAN issues 2015-01-20 15:51:42 -08:00
hetong007
eb01acfad8 improve demo of cv in R 2015-01-20 14:35:44 -08:00
hetong007
947f0a926d enable returning prediction in cv 2015-01-20 14:12:45 -08:00
tqchen
6937384e62 Squashed 'subtree/rabit/' changes from 85b7463..4ebe657
4ebe657 fix in cxx11

git-subtree-dir: subtree/rabit
git-subtree-split: 4ebe657dd7
2015-01-19 21:37:23 -08:00
tqchen
89d5e67b78 Merge commit '6937384e625dd44b181d0216fde6234be1b7c874' 2015-01-19 21:37:23 -08:00
tqchen
cd2bce4719 update with new rabit api 2015-01-19 21:32:25 -08:00
tqchen
ea50f8e030 Squashed 'subtree/rabit/' changes from 1db6449..85b7463
85b7463 change def of reducer to take function ptr
fe6366e add engine base
a98720e more deps

git-subtree-dir: subtree/rabit
git-subtree-split: 85b746394e
2015-01-19 21:26:25 -08:00
tqchen
25cf27d50f Merge commit 'ea50f8e030111f659dd69b89c86eba51abd39eba' 2015-01-19 21:26:25 -08:00
hetong
3b190123c8 update demo readme 2015-01-19 19:29:24 -08:00
hetong
c0c6951b73 fix bug in format of input 2015-01-19 19:26:25 -08:00
hetong
f295177b1d add nrow to getinfo 2015-01-19 13:36:53 -08:00
hetong
a1e188aa75 add nrow to getinfo 2015-01-19 13:35:11 -08:00
hetong
43c13d82ba add leaf example in R 2015-01-19 10:34:14 -08:00
tqchen
312546b99d quick fix 2015-01-19 10:00:28 -08:00
tqchen
7c6cf4bad8 quick fix 2015-01-19 09:59:33 -08:00
Tianqi Chen
1ea23d3390 Merge pull request #149 from tqchen/unity
add proptype of predleaf in R, fix bug in lambda rank
2015-01-19 09:08:19 -08:00
tqchen
632fdbbf5c add proptype of predleaf in R, fix bug in lambda rank 2015-01-19 09:07:37 -08:00
Tianqi Chen
9b3a601ede Merge pull request #148 from tqchen/unity
Distributed XGBoost from unity
2015-01-19 08:45:07 -08:00
tqchen
b9650f19c1 change tracker dir 2015-01-19 08:41:14 -08:00
tqchen
c1f84ba446 add note to subtree 2015-01-19 08:39:26 -08:00
tqchen
902f84cf4a ok 2015-01-19 08:37:17 -08:00
tqchen
9ea6b2f1b8 minor fix 2015-01-19 08:36:19 -08:00
tqchen
f0a412d224 update note 2015-01-19 08:34:35 -08:00
Tianqi Chen
e5c609271f add rabit to xgb 2015-01-19 08:16:54 -08:00
tqchen
ccba73e5d5 remove xgpred 2015-01-19 08:07:50 -08:00
tqchen
1211ea40c9 add single instance prediction 2015-01-19 08:07:22 -08:00
Tianqi Chen
748389f052 fix win compile 2015-01-19 00:29:03 -08:00
Tianqi Chen
8e8926550f fix of Rpack 2015-01-19 00:01:17 -08:00
tqchen
0b55fa6aff Merge branch 'unity' of ssh://github.com/tqchen/xgboost into unity 2015-01-18 22:56:33 -08:00
tqchen
631b092b25 changes 2015-01-18 22:56:29 -08:00
Tianqi Chen
f22ee7cb61 windows changes 2015-01-18 22:54:01 -08:00
tqchen
7780bc45c2 change R build script 2015-01-18 22:14:38 -08:00
tqchen
81749e6b63 Squashed 'subtree/rabit/' changes from c7282ac..1db6449
1db6449 remove include in -I, make things easier to direct compile

git-subtree-dir: subtree/rabit
git-subtree-split: 1db6449b01
2015-01-18 21:31:16 -08:00
tqchen
c51e01da2f Merge commit '81749e6b637997156c481e7f1d74fd319ba7b1d4' into unity 2015-01-18 21:31:16 -08:00
tqchen
ba0b950a84 add sync module 2015-01-18 21:31:09 -08:00
tqchen
d87691ec60 Squashed 'subtree/rabit/' content from commit c7282ac
git-subtree-dir: subtree/rabit
git-subtree-split: c7282acb2a
2015-01-18 21:08:17 -08:00
tqchen
152e08974d Merge commit 'd87691ec603db325d5b1c5db1186295a748df7cc' as 'subtree/rabit' 2015-01-18 21:08:17 -08:00
tqchen
07da390575 add subtree folder 2015-01-18 21:07:31 -08:00
tqchen
9695c51ce1 Merge branch 'master' into unity 2015-01-18 20:09:36 -08:00
tqchen
f49fd88de8 Merge branch 'unity'
Conflicts:
	.gitignore
	R-package/src/xgboost_R.cpp
	src/gbm/gblinear-inl.hpp
	tools/xgcombine_buffer.cpp
2015-01-18 20:09:21 -08:00
Tianqi Chen
d50079f993 Merge pull request #145 from pommedeterresautee/master
refactoring
2015-01-18 14:57:44 -08:00
El Potaeto
d84d27ae3d refactoring 2015-01-18 00:35:38 +01:00
tqchen
b898672753 ok 2015-01-15 22:03:32 -08:00
tqchen
90ec783e65 remove build 2015-01-15 22:01:55 -08:00
tqchen
4715672d76 chg 2015-01-15 22:01:29 -08:00
tqchen
b1df8039a0 ignore 2015-01-15 21:56:39 -08:00
tqchen
b1f89f29b8 cleanup multi-node 2015-01-15 21:55:56 -08:00
tqchen
b762231b02 change makefile to lazy checkpt, fix col splt code 2015-01-15 21:32:31 -08:00
Tianqi Chen
962c2432a0 Merge pull request #143 from cblsjtu/unity
modify doc
2015-01-14 10:07:33 -08:00
Boliang Chen
4d30fa2449 Merge branch 'unity' of github.com:tqchen/xgboost into unity
Conflicts:
	multi-node/hadoop/README.md
2015-01-14 22:36:39 +08:00
Boliang Chen
ede1222b02 modify doc 2015-01-14 22:15:31 +08:00
Tong He
bbbc6be58e Add vcd to the dependencies 2015-01-13 15:38:50 -08:00
tqchen
a53f0cd9bf doc chg 2015-01-12 11:55:42 -08:00
tqchen
9346c328cb chg 2015-01-12 11:53:40 -08:00
tqchen
2a9a864b11 ok 2015-01-12 11:50:18 -08:00
tqchen
6b7f20c002 chgs 2015-01-12 11:49:42 -08:00
tqchen
5e0e8a5ff7 changes 2015-01-12 11:47:46 -08:00
tqchen
083c032319 Merge branch 'cblsjtu-unity' into unity 2015-01-12 11:41:59 -08:00
tqchen
48a44b24f9 Merge branch 'unity' of https://github.com/cblsjtu/xgboost into cblsjtu-unity
Conflicts:
	multi-node/hadoop/README.md
	multi-node/hadoop/mushroom.hadoop.conf
	multi-node/hadoop/run_hadoop_mushroom.sh
2015-01-12 11:41:07 -08:00
Tianqi Chen
d57cb4f17b Update mushroom.hadoop.conf 2015-01-12 09:02:53 -08:00
tqchen
62a108a7c2 chg of hadoop script 2015-01-11 21:02:38 -08:00
Tianqi Chen
166e7525da Merge pull request #142 from pommedeterresautee/master
avoid warning message when a tree is just made of one leaf
2015-01-11 16:02:56 -08:00
El Potaeto
48c1911bc4 fix error 2015-01-11 23:39:24 +01:00
El Potaeto
d441a9d382 avoid error when a tree is just made of one leaf 2015-01-11 23:37:02 +01:00
Tianqi Chen
9a2ad91b48 Merge pull request #138 from pommedeterresautee/master
new parameters, refactoring...
2015-01-11 14:27:38 -08:00
Tianqi Chen
15bf8677da Merge pull request #140 from EricChenDM/unity
yarn script
2015-01-11 10:40:04 -08:00
chenshuaihua
0111a14aef yarn script 2015-01-11 23:57:52 +08:00
Boliang Chen
df3f87c182 add more details 2015-01-11 18:20:16 +08:00
Boliang Chen
fdbca6013d modify 2015-01-11 17:57:41 +08:00
El Potaeto
31a3b38ef8 add new parameters model to avoid the use of dump file for functions plot, dt.tree, importance
add new size parameter for plot function
2015-01-11 09:40:55 +01:00
Boliang Chen
ef2518364c change to minimal setting 2015-01-11 16:07:00 +08:00
Boliang Chen
525c1594e5 revise the script 2015-01-11 16:06:19 +08:00
Tianqi Chen
c38f7109bd Merge pull request #137 from cblsjtu/unity
Unity hadoop version scripts
2015-01-10 23:47:52 -08:00
tqchen
69e079941e allow pred to stdout 2015-01-10 23:46:29 -08:00
Boliang Chen
ceabf5755f hadoop version conf 2015-01-11 15:44:16 +08:00
Boliang Chen
fb65356dd4 change file name 2015-01-11 15:41:46 +08:00
Boliang Chen
2f95968a1c ok 2015-01-11 15:34:55 +08:00
Boliang Chen
966416e69c Merge remote-tracking branch 'tqchen/unity' into unity 2015-01-11 13:48:29 +08:00
tqchen
db4637b085 Merge branch 'unity' of ssh://github.com/tqchen/xgboost into unity 2015-01-10 21:33:16 -08:00
tqchen
9eaf073e3c change default distributed mode to row 2015-01-10 21:33:07 -08:00
Boliang Chen
d5e9b1d4ea delete hadoop conf 2015-01-11 13:08:52 +08:00
El Potaeto
c8c5789efd add new parameters to several functions avoid the need of a text dump 2015-01-11 03:06:41 +01:00
El Potaeto
70df227689 dump function is now memory safe 2015-01-11 01:04:54 +01:00
Tianqi Chen
d348f83c17 Merge pull request #136 from cblsjtu/unity
hadoop example
2015-01-10 09:31:06 -08:00
Boliang Chen
7665dd1ed2 rename 2015-01-11 00:04:47 +08:00
Boliang Chen
74348c8001 initialize 2015-01-11 00:00:03 +08:00
Boliang Chen
24f99220cb fix bugs 2015-01-10 23:59:25 +08:00
Boliang Chen
61a43111a7 hadoop version of xgboost binary classification script 2015-01-10 12:30:00 +08:00
Boliang Chen
e20d4f4387 comment some parameters not supported by hadoop version of xgboost 2015-01-10 12:26:43 +08:00
Tianqi Chen
72f6fbd46f Merge pull request #135 from pommedeterresautee/master
fix a small bug in CV function
2015-01-09 10:06:22 -08:00
El Potaeto
359889e3d6 fix a small bug in CV function 2015-01-09 19:03:47 +01:00
Tianqi Chen
75a75bc1e9 Merge pull request #134 from pommedeterresautee/master
nice work! merged to master.
2015-01-09 09:46:53 -08:00
El Potaeto
99b4ead937 add new dependency on DiagrammeR 2015-01-09 18:28:10 +01:00
El Potaeto
a3493934d1 documentation example change 2015-01-09 18:26:56 +01:00
El Potaeto
51935851bd fix plenty of small bugs 2015-01-09 18:24:12 +01:00
El Potaeto
b656ca1554 reindent 2015-01-09 11:54:23 +01:00
El Potaeto
d96bd15b7d small fix in the C dump code 2015-01-09 11:52:40 +01:00
El Potaeto
31d0e8f65d better doc of dump function 2015-01-09 11:14:08 +01:00
El Potaeto
9d6eecf34e small change in import lib 2015-01-09 11:07:53 +01:00
El Potaeto
10f755e055 only replace tabulation which begins a line (avoid wrong replacement in feature name) 2015-01-09 11:06:56 +01:00
El Potaeto
3e1eea0eea refactor dump function to adapt to the new possibilities of exporting a String 2015-01-09 00:14:01 +01:00
El Potaeto
6fd8bbe71a C part export a model dump string 2015-01-08 23:47:00 +01:00
El Potaeto
3d0bbae2c2 refactoring of importance function 2015-01-07 18:18:52 +01:00
El Potaeto
d532f04394 add new function to read model and use it in the plot function 2015-01-07 17:47:50 +01:00
El Potaeto
e380e4facf refactoring for perf 2015-01-07 17:09:56 +01:00
El Potaeto
cce26756bf add style option 2015-01-07 17:05:34 +01:00
pommedeterresautee
9e20893d35 Change in aesthetic
Improve documentation
2015-01-06 23:57:33 +01:00
El Potaeto
3dd202a19e Add stat indicators in plot 2015-01-06 18:18:55 +01:00
El Potaeto
94d070da60 add limit number of trees option 2015-01-06 13:59:29 +01:00
El Potaeto
a6c588f90d fix arg check 2015-01-06 13:59:14 +01:00
Boliang Chen
f82732a362 add hadoop folder 2015-01-06 17:09:15 +08:00
El Potaeto
c64bfad5bb fix import issue 2015-01-05 19:35:33 +01:00
El Potaeto
59412f64ad Merge remote-tracking branch 'upstream/master' 2015-01-05 19:30:29 +01:00
El Potaeto
f793df671b Change code to look like a function 2015-01-05 19:26:26 +01:00
El Potaeto
3d068b4e1a new documentation
new import
2015-01-05 19:26:09 +01:00
El Potaeto
b9799c6ac4 refactor plot function 2015-01-04 22:42:17 +01:00
El Potaeto
ffbd78fce4 use style CSS class instead of q style per item 2015-01-04 22:40:31 +01:00
El Potaeto
f6290ad792 plot all trees 2015-01-04 21:56:41 +01:00
El Potaeto
33bb168574 basis to plot 2015-01-04 17:23:53 +01:00
tqchen
2925236fab change dump stats 2015-01-04 02:35:24 -08:00
El Potaeto
8b45ef07ca build data.table from raw model data 2015-01-04 11:21:39 +01:00
El Potaeto
cfe5015e54 small fix in parsing 2015-01-04 11:21:03 +01:00
El Potaeto
cdea1685e5 Add a new verbose parameter to print progress during the process (set to true by default to not change behavior of existing code) + source code refactoring 2015-01-02 11:21:53 +01:00
Tianqi Chen
61df646eed Merge pull request #132 from pommedeterresautee/master
Return history as data.table for cross validation + bring back linear model dump to master + other fixes
2015-01-02 17:06:24 +08:00
El Potaeto
4d0d65837d parse history first line to guess which columns are required 2015-01-01 22:43:23 +01:00
El Potaeto
8bbe45eed2 fix some missing imports 2015-01-01 16:09:03 +01:00
El Potaeto
a524a51a06 return history as data.table for cross validation + documentation 2015-01-01 16:05:43 +01:00
El Potaeto
34aaeff3d9 small documentation change 2015-01-01 14:57:48 +01:00
El Potaeto
5e5500d6d3 rewording 2015-01-01 13:50:28 +01:00
El Potaeto
901904b535 linear text dump model 2015-01-01 13:50:05 +01:00
Tianqi Chen
3974231440 Merge pull request #130 from pommedeterresautee/master
Improve demo text (more explanation)
2014-12-31 18:32:13 +08:00
El Potaeto
d07be2bb96 Username parameter is deprecated in install_function (see doc of the package for more information). 2014-12-31 11:03:51 +01:00
El Potaeto
4f0ae53974 text change 2014-12-31 10:49:05 +01:00
El Potaeto
9998575c32 Small text improvement 2014-12-31 10:47:57 +01:00
El Potaeto
4cc3790b76 Improve explanation, add new concepts. 2014-12-31 10:36:10 +01:00
Tianqi Chen
4183c239ca Merge pull request #128 from mhue/master
Fixed minor typos.
2014-12-31 09:04:30 +08:00
El Potaeto
c3d8f21df3 change assignation sign 2014-12-31 00:52:53 +01:00
Bing Xu
9267e3b368 Merge pull request #129 from pommedeterresautee/master
Add demo code
2014-12-30 16:51:11 -07:00
El Potaeto
006578e2e6 fix demo index 2014-12-31 00:46:12 +01:00
El Potaeto
97fd9b47d4 Add new demo 2014-12-31 00:39:13 +01:00
Martial Hue
79731f48b6 Fixed minor typos. 2014-12-30 17:50:24 +01:00
El Potaeto
7558a94507 Update wlkthrough R demo code to include variable importance. 2014-12-30 16:38:56 +01:00
El Potaeto
8e74bcdd05 remove unneeded text... 2014-12-30 16:29:13 +01:00
El Potaeto
2364e914bd Documentation regenerated with fixes 2014-12-30 16:24:16 +01:00
El Potaeto
e64cb99f89 Missing parameter documentation
Fix data documentation
2014-12-30 16:22:50 +01:00
El Potaeto
af31397ec2 Missing parameter documentation 2014-12-30 16:22:24 +01:00
El Potaeto
31ed2813bd Spell 2014-12-30 16:05:12 +01:00
El Potaeto
45a006f367 R demo code README 2014-12-30 16:04:43 +01:00
El Potaeto
345b93fcfa fix link 2014-12-30 15:03:21 +01:00
El Potaeto
d8eb978f98 Update readme with new win on Kaggle 2014-12-30 15:00:52 +01:00
cblsjtu
01f640f8a6 Merge pull request #1 from tqchen/unity
Unity
2014-12-30 20:26:12 +08:00
Tianqi Chen
39bb719063 Merge pull request #125 from pommedeterresautee/master
Take gain into account for feature importance
2014-12-30 19:50:19 +08:00
El Potaeto
c6f76fab56 add new Gain and Weight columns.
documentation updated.
2014-12-30 12:32:58 +01:00
El Potaeto
c754fd4ad0 documentation wording 2014-12-30 12:32:21 +01:00
El Potaeto
3694772bde Add a new Weight and Gain column.
Update documentation.
2014-12-30 12:16:13 +01:00
tqchen
5ad100b5a3 now support distributed evaluation 2014-12-29 19:24:08 -08:00
tqchen
c395c5bed3 update build script 2014-12-29 17:41:47 -08:00
El Potaeto
78813d8f78 wording 2014-12-30 00:12:01 +01:00
El Potaeto
263f7fa69d Take gain into account to discover most important variables 2014-12-29 23:57:41 +01:00
El Potaeto
dba1ce7050 new dependency over stringr 2014-12-29 23:57:01 +01:00
El Potaeto
9b6a14a99d regeneration of documentation 2014-12-29 23:56:31 +01:00
El Potaeto
755be4b846 Add variable type checks 2014-12-29 10:31:17 +01:00
tqchen
6b96737811 add dump statistics 2014-12-28 17:45:37 -08:00
Tianqi Chen
0c7e090c19 Merge pull request #124 from pommedeterresautee/master
Add a new function to see importance of features in a model
2014-12-28 20:06:55 +08:00
El Potaeto
99af2c8ffd Documentation of the function 2014-12-28 11:33:14 +01:00
El Potaeto
84fb89af70 fix small bug introduced in refactoring 2014-12-28 11:30:55 +01:00
El Potaeto
2154a160a3 refactoring of validation to improve source code readability. 2014-12-28 11:18:26 +01:00
El Potaeto
151285300b change version number + date 2014-12-28 11:02:48 +01:00
El Potaeto
46862e561b Add .gitignore 2014-12-28 10:47:02 +01:00
El Potaeto
ce83611a72 generated documentation with ROxygen2 2014-12-28 10:46:31 +01:00
El Potaeto
e63c79d6c6 new function cv.importance + documentation 2014-12-28 10:45:47 +01:00
El Potaeto
8c17a86b38 Update Namespace with new function 2014-12-28 10:24:43 +01:00
El Potaeto
1d64cd8896 Add new dependency 2014-12-28 10:24:08 +01:00
El Potaeto
4369a57270 fix data labels 2014-12-28 09:56:55 +01:00
tqchen
c8f422b3b9 add dump to linear model 2014-12-24 02:56:32 -08:00
tqchen
6d7ef172ef add base64 model format 2014-12-24 02:33:50 -08:00
tqchen
c8396ca24e add mock exec 2014-12-21 18:47:56 -08:00
tqchen
677475529f fix the row split recovery, add per iteration random number seed 2014-12-21 17:31:42 -08:00
tqchen
eff5c6baa8 push in row mock file 2014-12-21 04:36:18 -08:00
tqchen
d603852828 rm boost str 2014-12-21 00:17:27 -08:00
tqchen
31eedfea59 pas mock, need to fix rabit lib for not initialization 2014-12-21 00:14:00 -08:00
tqchen
b078663982 ok 2014-12-20 16:39:39 -08:00
tqchen
7a35e1a906 change hist update to lazy 2014-12-20 05:02:38 -08:00
tqchen
deb21351b9 add rabit checkpoint to xgb 2014-12-20 01:05:40 -08:00
tqchen
8e16cc4617 change allreduce lib to rabit library, xgboost now run with rabit 2014-12-20 00:17:09 -08:00
Tianqi Chen
646f33d01d Update README.md 2014-12-12 05:47:00 -08:00
Tianqi Chen
a50fd27fd3 Update README.md 2014-12-12 05:46:32 -08:00
Tianqi Chen
5ae99372d6 Update simple_dmatrix-inl.hpp 2014-11-26 09:13:49 -08:00
Tianqi Chen
be5fb800d5 Merge pull request #112 from tfgit/master
Fixed README
2014-11-25 19:29:41 -08:00
Ted Fujimoto
baf41d589d Fixed README 2014-11-25 22:17:36 -05:00
Tianqi Chen
8d7dbc65b3 Merge pull request #111 from tfgit/master
OS X OpenMP support instructions
2014-11-25 19:12:42 -08:00
Ted Fujimoto
198489438f Added OS X OpenMP instructions 2014-11-25 21:42:13 -05:00
Ted Fujimoto
c356a0acc2 Remove tools folder 2014-11-25 21:27:50 -05:00
Tianqi Chen
cdcfa5687a Update socket.h 2014-11-23 22:46:57 -08:00
tqchen
f53be2884a ok 2014-11-23 22:42:44 -08:00
Tianqi Chen
f805ecb5f3 fix a bug in node sindex set 2014-11-23 22:35:30 -08:00
tqchen
3e162ceda6 windows strange 2014-11-23 22:21:15 -08:00
tqchen
35bf2101fe seems a prob in win 2014-11-23 22:18:28 -08:00
Tianqi Chen
fde580b08e fix windows run 2014-11-23 22:12:55 -08:00
tqchen
77ffd0465b ok 2014-11-23 21:36:22 -08:00
tqchen
78ca72b9c7 start work on win 2014-11-23 21:34:15 -08:00
tqchen
d2f151ef5a bring it back alive again 2014-11-23 21:27:16 -08:00
Tianqi Chen
7f3dc967cf changes in socket, a bit work in linux side first 2014-11-23 21:21:52 -08:00
tqchen
db2adb6885 start check windows compatiblity 2014-11-23 20:59:10 -08:00
Tianqi Chen
2e444f8338 remove warning from MSVC need another round of check 2014-11-23 20:52:13 -08:00
tqchen
b55fe80350 add row map example 2014-11-23 18:15:42 -08:00
tqchen
372de9f968 check in conf 2014-11-23 17:35:21 -08:00
tqchen
373620503a ok 2014-11-23 14:08:34 -08:00
tqchen
5f08313cb2 make wrapper ok 2014-11-23 14:03:59 -08:00
tqchen
69b2f31098 bugfix in allreduce 2014-11-23 11:31:34 -08:00
tqchen
115424826b basic test pass 2014-11-23 11:15:48 -08:00
tqchen
c499dd0f0c start testing allreduce 2014-11-22 22:55:43 -08:00
tqchen
cb1c34aef0 add nonblocking mode 2014-11-22 17:15:05 -08:00
tqchen
67c5d8a2e6 allreduce server side ok, need to add master 2014-11-22 17:12:19 -08:00
tqchen
4864220702 have the function, ready, need initializer 2014-11-22 12:15:30 -08:00
tqchen
7ec3fc936a check in allreduce tcp, check if there could be more concise form 2014-11-21 22:54:11 -08:00
tqchen
b6e1b19205 checkin socket module 2014-11-21 16:09:28 -08:00
tqchen
84dcab6795 checkin socket module 2014-11-21 16:09:26 -08:00
Tianqi Chen
c29a600d46 Update README.md 2014-11-21 09:48:59 -08:00
tqchen
168bb0d0c9 add predict leaf indices 2014-11-21 09:32:09 -08:00
Tianqi Chen
6ed82edad7 Merge pull request #106 from tqchen/master
pull master into unity
2014-11-21 08:56:01 -08:00
Tianqi Chen
d4103ea7ea Update README.md 2014-11-20 22:01:26 -08:00
Tong He
c16e0f6809 Update predict.xgb.Booster.R
add parameter missing
2014-11-20 15:19:53 -08:00
Tong He
98ee7e8057 Update xgboost.R
add parameter missing
2014-11-20 15:14:05 -08:00
Tong He
20817b56f3 Update xgb.cv.R
add parameter missing
2014-11-20 15:14:00 -08:00
Tong He
bbd7098e51 Update utils.R
add parameter missing
2014-11-20 15:13:28 -08:00
tqchen
ed87eb61bd allow nan as mssing 2014-11-20 13:14:04 -08:00
tqchen
23fbf079b9 fix bug in row 2014-11-20 12:56:30 -08:00
tqchen
974202eb55 check pipe, commit optimization for hist 2014-11-20 11:22:09 -08:00
tqchen
6b674b491f Merge branch 'unity' of ssh://github.com/tqchen/xgboost into unity 2014-11-19 20:09:38 -08:00
tqchen
9af464303a checkin row continue training 2014-11-19 20:09:26 -08:00
Tianqi Chen
b595854e8c Update README.md 2014-11-19 20:08:11 -08:00
tqchen
970dd58dc2 checkin continue training 2014-11-19 20:06:08 -08:00
tqchen
26e5eae6f2 ok 2014-11-19 19:27:04 -08:00
tqchen
41eac089c8 chg 2014-11-19 19:25:49 -08:00
tqchen
338117867b small change 2014-11-19 19:24:20 -08:00
tqchen
a0342cb196 small change 2014-11-19 19:22:36 -08:00
tqchen
3b48a9f359 checkin split row 2014-11-19 19:21:56 -08:00
tqchen
c42ba8d281 get multinode in 2014-11-19 19:19:53 -08:00
tqchen
7c3a392136 compile 2014-11-19 15:28:09 -08:00
tqchen
55e62a7120 still need to test row merge 2014-11-19 11:44:24 -08:00
tqchen
da54f5e5d8 add note for col 2014-11-19 11:37:54 -08:00
tqchen
03e24cf590 check multinode 2014-11-19 11:22:17 -08:00
tqchen
54e2ed90d7 recheck column mode 2014-11-19 11:21:07 -08:00
tqchen
dffcbc838b Merge branch 'unity' of ssh://github.com/tqchen/xgboost into unity
Conflicts:
	src/tree/updater_histmaker-inl.hpp
2014-11-19 09:55:05 -08:00
tqchen
fa1581b94c cqmaker ok 2014-11-19 09:51:30 -08:00
tqchen
32beb56ba3 only need to add in create hist col base 2014-11-18 22:21:41 -08:00
tqchen
08e9813c9b potential BUG in skmaker? 2014-11-18 21:23:36 -08:00
tqchen
1b66a87456 checkin skmaker 2014-11-18 20:57:28 -08:00
tqchen
303f8b9bc5 hack to make the propose fast in one pass, start sketchmaker 2014-11-18 11:25:54 -08:00
tqchen
ce7ecadf5e simplify 2014-11-18 10:52:18 -08:00
tqchen
5de0a2cdc0 sorted base sketch maker 2014-11-18 10:19:18 -08:00
tqchen
5e8e9a9b74 updated base 2014-11-17 10:49:53 -08:00
tqchen
8874234e5e check in basemaker 2014-11-16 22:23:33 -08:00
tqchen
d11445e0b1 add in sync 2014-11-16 22:01:22 -08:00
tqchen
8ed585a7a2 check in two bad ones, start think of column distribut cut row 2014-11-16 13:31:50 -08:00
tqchen
5061d55725 alrite 2014-11-16 11:47:21 -08:00
tqchen
129fee64f3 fix regression 2014-11-16 11:38:21 -08:00
tqchen
02c2278f96 ok 2014-11-15 21:18:15 -08:00
tqchen
daa28f238e fix compile, need final leaf node? 2014-11-15 21:02:19 -08:00
tqchen
c86b83ea04 a version that compile 2014-11-15 17:41:03 -08:00
tqchen
c1f1bb9206 first ver 2014-11-15 09:46:30 -08:00
tqchen
076159cf7a remove cstdio 2014-11-14 14:37:13 -08:00
Tianqi Chen
b66bcb7974 Merge pull request #100 from travisbrady/master
add ifdef __cplusplus to wrapper header file
2014-11-14 14:33:49 -08:00
Travis Brady
42712988af add ifdef __cplusplus to wrapper header file 2014-11-14 15:48:13 -06:00
tqchen
698c010247 add example 2014-11-10 22:09:01 -08:00
tqchen
e7ea87b5fd ok for now 2014-11-10 22:03:42 -08:00
tqchen
9d101b47f9 optimize heavy hitter 2014-11-10 21:18:37 -08:00
tqchen
b426eef527 chg begin end type 2014-11-10 17:24:44 -08:00
tqchen
9855a90142 unified gk and wq 2014-11-10 17:06:10 -08:00
tqchen
7b8ba268dc commit in quantile test 2014-11-10 16:44:07 -08:00
tqchen
d4c4ee0b01 mostly correct\n 2014-11-09 23:34:45 -08:00
tqchen
69874dc571 init check 2014-11-09 21:56:56 -08:00
tqchen
5561dd9cb0 fix bug in queue2summary 2014-11-09 21:09:07 -08:00
tqchen
7c1ec78a01 before test quantile 2014-11-09 18:03:36 -08:00
tqchen
0e6b899d07 quantile 2014-11-09 16:02:38 -08:00
tqchen
aace84c349 pass group data test 2014-11-06 15:58:36 -08:00
tqchen
539fce2856 ok 2014-11-06 15:37:23 -08:00
tqchen
ca96468745 everything is ready, except for propose 2014-11-02 21:52:59 -08:00
Tianqi Chen
b2850ae0f9 Update README.md 2014-10-23 09:43:03 -07:00
Tianqi Chen
c17c0f3197 Update README.md 2014-10-23 09:41:12 -07:00
tqchen
96c5196647 remv debug 2014-10-20 18:06:15 -07:00
tqchen
23eaa7ed32 add quantile sketch 2014-10-20 18:04:39 -07:00
tqchen
dcd0dd5e26 finish find split, next to do quantile sketch 2014-10-18 10:24:29 -07:00
tqchen
a7bc769971 incomplete histmaker 2014-10-17 17:55:07 -07:00
tqchen
c2fa390181 move sync tree to pruner, pruner is now distributed 2014-10-17 14:53:43 -07:00
tqchen
a68ac8033e refresher is now distributed 2014-10-17 14:48:32 -07:00
tqchen
9df9e07f9b minor change in main 2014-10-17 14:11:46 -07:00
tqchen
f6d61f02f6 fix load bug 2014-10-16 21:47:01 -07:00
tqchen
3f3c90c3c0 add part_load col 2014-10-16 19:41:43 -07:00
tqchen
f512f08437 finish mushroom example 2014-10-16 18:06:47 -07:00
tqchen
0cf2dd39ea new change for mpi 2014-10-16 15:12:10 -07:00
tqchen
a21df0770d make clear seperation 2014-10-16 13:03:42 -07:00
tqchen
47145a7fac ok, now work on update position 2014-10-16 11:56:55 -07:00
tqchen
aefe58a207 middle version 2014-10-16 10:38:49 -07:00
tqchen
6680bffaae chg 2014-10-15 21:45:13 -07:00
tqchen
f2577fec86 intial version of sync wrapper 2014-10-15 21:39:42 -07:00
tqchen
e295128973 add bitmap . 2014-10-15 14:30:09 -07:00
tqchen
d0daecb4d3 add bitmap . 2014-10-15 14:30:06 -07:00
Tianqi Chen
f2cceb37eb Update README.md 2014-10-13 09:21:43 -07:00
tqchen
c957e1a648 Merge branch 'master' of ssh://github.com/tqchen/xgboost 2014-10-01 09:20:16 -07:00
tqchen
78efa13d41 add example with additional attr 2014-10-01 09:20:06 -07:00
Tianqi Chen
d6b60a1e4a Update README.md 2014-09-18 17:53:20 -07:00
Tianqi Chen
d3f7952991 Update README.md 2014-09-18 17:52:41 -07:00
tqchen
91e34c6fb4 ok 2014-09-12 21:26:38 -07:00
tqchen
bf2426f3cd some changes 2014-09-12 17:31:06 -07:00
tqchen
3a0be47b1c add tmp file 2014-09-12 15:52:39 -07:00
tqchen
87cc53f0cd make basic combine buf 2014-09-10 21:38:50 -07:00
tqchen
fe9e89cadd Merge branch 'unity' of ssh://github.com/tqchen/xgboost into unity 2014-09-10 21:33:51 -07:00
tqchen
0e8846a42f ok 2014-09-10 13:51:34 -07:00
Tianqi Chen
496301585a Update README.md 2014-09-09 21:43:45 -07:00
Tianqi Chen
4275403004 Update README.md 2014-09-09 21:38:01 -07:00
Tianqi Chen
c380342c5f Update README.md 2014-09-09 21:35:24 -07:00
Tianqi Chen
2fec85ab8a Update README.md 2014-09-09 21:34:10 -07:00
Tianqi Chen
86bdef1f19 Update README.md 2014-09-09 21:31:40 -07:00
Tianqi Chen
9e701440e7 Update README.md 2014-09-09 21:28:58 -07:00
Tianqi Chen
1a6af1aacf Update README.md 2014-09-09 21:28:19 -07:00
Tianqi Chen
011df2993a Update README.md 2014-09-09 21:27:01 -07:00
tqchen
7d0d3f07ef Merge branch 'unity' of ssh://github.com/tqchen/xgboost into unity 2014-09-08 21:52:34 -07:00
tqchen
a3806398b9 delete old cvpack 2014-09-08 21:34:42 -07:00
tqchen
a3d5930f26 Merge branch 'unity' of ssh://github.com/tqchen/xgboost into unity 2014-09-08 16:20:48 -07:00
tqchen
e90b25a381 add object bound checking 2014-09-08 16:20:41 -07:00
Tianqi Chen
4e44dd83a7 Merge pull request #72 from giuliohome/master
python 3 encoding
2014-09-08 14:49:53 -07:00
giuliohome
02e41be857 python 3 encoding 2014-09-08 23:40:04 +02:00
tqchen
d4ab359be1 fix 2014-09-07 20:01:03 -07:00
tqchen
19a1ee24a5 try predpath 2014-09-07 18:40:15 -07:00
tqchen
75aa5bd258 Merge branch 'master' into unity 2014-09-07 18:16:55 -07:00
tqchen
ae3621b372 Merge branch 'unity'
Conflicts:
	R-package/src/xgboost_R.cpp
	wrapper/xgboost.py
2014-09-07 18:16:49 -07:00
tqchen
df3eafc5ba chg mldata to page 2014-09-04 14:20:52 -07:00
tqchen
46cddb80f4 Merge branch 'mastet push origin unityr' into unity 2014-09-03 13:52:11 -07:00
tqchen
5f6e849b21 Merge branch 'unity'
Conflicts:
	src/utils/io.h
	wrapper/xgboost.py
2014-09-03 13:52:03 -07:00
tqchen
244a589e5d change include order, so that Rinternal does not disturb us 2014-09-03 11:31:05 -07:00
tqchen
401d648372 some lint 2014-09-02 17:49:39 -07:00
tqchen
e6e467ad60 more ignore 2014-09-02 17:40:30 -07:00
tqchen
f3360d173b pass trival test 2014-09-02 17:38:51 -07:00
tqchen
226d26d40c still buggy 2014-09-02 17:18:17 -07:00
tqchen
a89e3063e6 untested version of cpage 2014-09-02 15:34:11 -07:00
tqchen
4b9aeea89c finish the fmatrix 2014-09-02 13:14:54 -07:00
tqchen
76c513b191 t push origin unityMerge branch 'master' into unity 2014-09-02 11:22:57 -07:00
tqchen
eeb04a0603 Merge remote-tracking branch 'origin/unity'
Conflicts:
	R-package/src/Makevars
	R-package/src/Makevars.win
	src/utils/io.h
	wrapper/xgboost.py
2014-09-02 11:22:47 -07:00
tqchen
e43bb91185 add matrix builder 2014-09-01 21:30:03 -07:00
tqchen
9d3e09ff2a make rowbatch page flexible 2014-09-01 20:44:15 -07:00
tqchen
7d1e9f06d4 add fmatrix in, todo add buffer file 2014-09-01 10:45:05 -07:00
tqchen
e3153b976c chgs 2014-08-31 22:25:30 -07:00
tqchen
0a7cfb32c6 add fmatrix, fight tmr 2014-08-31 21:58:01 -07:00
tqchen
e18a4fc5b6 Merge branch 'master' into unity 2014-08-30 15:01:52 -07:00
tqchen
602558c5d6 Merge branch 'unity'
Conflicts:
	R-package/src/Makevars
	R-package/src/Makevars.win
2014-08-30 15:01:36 -07:00
Tianqi Chen
366ac95ad3 windows check 2014-08-29 21:27:03 -07:00
tqchen
9830674b75 seems page is ok, try add col tmr 2014-08-29 21:04:40 -07:00
tqchen
7bc1c3ee79 various fix of page 2014-08-29 20:54:24 -07:00
tqchen
ce772c2f3e first check of page 2014-08-29 19:59:19 -07:00
tqchen
d0e27482ef fix compiler error 2014-08-29 18:44:02 -07:00
tqchen
ce2d34ecd4 check unity back 2014-08-29 18:35:26 -07:00
tqchen
551b3b70f1 check unity back 2014-08-29 18:31:24 -07:00
425 changed files with 51381 additions and 16982 deletions

45
.gitignore vendored
View File

@@ -2,7 +2,7 @@
*.slo
*.lo
*.o
*.page
# Compiled Dynamic libraries
*.so
*.dylib
@@ -20,12 +20,12 @@
*buffer
*model
*pyc
*train
*test
*.train
*.test
*.tar
*group
*rar
*vali
*data
*sdf
Release
*exe*
@@ -36,7 +36,6 @@ ipch
*log
Debug
*suo
*test*
.Rhistory
*.dll
*i386
@@ -44,3 +43,39 @@ Debug
*dump
*save
*csv
.Rproj.user
*.cpage.col
*.cpage
*.Rproj
./xgboost
./xgboost.mpi
./xgboost.mock
#.Rbuildignore
R-package.Rproj
*.cache*
#java
java/xgboost4j/target
java/xgboost4j/tmp
java/xgboost4j-demo/target
java/xgboost4j-demo/data/
java/xgboost4j-demo/tmp/
java/xgboost4j-demo/model/
nb-configuration*
# Eclipse
.project
.cproject
.pydevproject
.settings/
build
config.mk
xgboost
*.data
build_plugin
dmlc-core
.idea
recommonmark/
tags
*.iml
*.class
target
*.swp

6
.gitmodules vendored Normal file
View File

@@ -0,0 +1,6 @@
[submodule "dmlc-core"]
path = dmlc-core
url = https://github.com/dmlc/dmlc-core
[submodule "rabit"]
path = rabit
url = https://github.com/dmlc/rabit

74
.travis.yml Normal file
View File

@@ -0,0 +1,74 @@
# disable sudo for container build.
sudo: false
# Enabling test on Linux and OS X
os:
- linux
- osx
# Use Build Matrix to do lint and build seperately
env:
matrix:
# code lint
- TASK=lint
# r package test
- TASK=r_test
# python package test
- TASK=python_test
- TASK=python_lightweight_test
# java package test
- TASK=java_test
# cmake test
- TASK=cmake_test
os:
- linux
- osx
matrix:
exclude:
- os: osx
env: TASK=lint
- os: linux
env: TASK=r_test
- os: osx
env: TASK=java_test
- os: osx
env: TASK=python_lightweight_test
# dependent apt packages
addons:
apt:
packages:
- doxygen
- wget
- libcurl4-openssl-dev
- unzip
- graphviz
before_install:
- source dmlc-core/scripts/travis/travis_setup_env.sh
- export PYTHONPATH=${PYTHONPATH}:${PWD}/python-package
- echo "MAVEN_OPTS='-Xmx2048m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=512m'" > ~/.mavenrc
install:
- source tests/travis/setup.sh
script:
- tests/travis/run_test.sh
cache:
directories:
- ${HOME}/.cache/usr
- ${HOME}/.cache/pip
before_cache:
- dmlc-core/scripts/travis/travis_before_cache.sh
after_failure:
- tests/travis/travis_after_failure.sh
notifications:
email:
on_success: change
on_failure: always

View File

@@ -1,22 +0,0 @@
Change Log
=====
xgboost-0.1
=====
* Initial release
xgboost-0.2x
=====
* Python module
* Weighted samples instances
* Initial version of pairwise rank
xgboost-0.3
=====
* Faster tree construction module
- Allows subsample columns during tree construction via ```bst:col_samplebytree=ratio```
* Support for boosting from initial predictions
* Experimental version of LambdaRank
* Linear booster is now parallelized, using parallel coordinated descent.
* Add [Code Guide](src/README.md) for customizing objective function and evaluation
* Add R module

79
CMakeLists.txt Normal file
View File

@@ -0,0 +1,79 @@
cmake_minimum_required (VERSION 2.6)
project (xgboost)
find_package(OpenMP)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -fPIC")
# Make sure we are using C++11
# Visual Studio 12.0 and newer supports enough c++11 to make this work
if(MSVC AND MSVC_VERSION LESS 1800)
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
else()
# GCC 4.6 with c++0x supports enough to make this work
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
endif()
#Make sure we are using the static runtime
if(MSVC)
set(variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
foreach(variable ${variables})
if(${variable} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
endif()
endforeach()
endif()
include_directories (
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/dmlc-core/include
${PROJECT_SOURCE_DIR}/rabit/include
)
file(GLOB SOURCES
src/c_api/*.cc
src/common/*.cc
src/data/*.cc
src/gbm/*.cc
src/metric/*.cc
src/objective/*.cc
src/tree/*.cc
src/*.cc
)
set(RABIT_SOURCES
rabit/src/allreduce_base.cc
rabit/src/allreduce_robust.cc
rabit/src/engine.cc
rabit/src/c_api.cc
)
add_subdirectory(dmlc-core)
add_library(rabit STATIC ${RABIT_SOURCES})
add_executable(xgboost ${SOURCES})
add_library(libxgboost SHARED ${SOURCES})
target_link_libraries(xgboost dmlccore rabit)
target_link_libraries(libxgboost dmlccore rabit)

62
CONTRIBUTORS.md Normal file
View File

@@ -0,0 +1,62 @@
Contributors of DMLC/XGBoost
============================
XGBoost has been developed and used by a group of active community. Everyone is more than welcomed to is a great way to make the project better and more accessible to more users.
Comitters
---------
Committers are people who have made substantial contribution to the project and granted write access to the project.
* [Tianqi Chen](https://github.com/tqchen), University of Washington
- Tianqi is a PhD working on large-scale machine learning, he is the creator of the project.
* [Tong He](https://github.com/hetong007), Simon Fraser University
- Tong is a master student working on data mining, he is the maintainer of xgboost R package.
* [Bing Xu](https://github.com/antinucleon)
- Bing is the original creator of xgboost python package and currently the maintainer of [XGBoost.jl](https://github.com/antinucleon/XGBoost.jl).
* [Michael Benesty](https://github.com/pommedeterresautee)
- Micheal is a lawyer, data scientist in France, he is the creator of xgboost interactive analysis module in R.
* [Yuan Tang](https://github.com/terrytangyuan)
- Yuan is a data scientist in Chicago, US. He contributed mostly in R and Python packages.
Become a Comitter
-----------------
XGBoost is a opensource project and we are actively looking for new comitters who are willing to help maintaining and lead the project.
Committers comes from contributors who:
* Made substantial contribution to the project.
* Willing to spent time on maintaining and lead the project.
New committers will be proposed by current comitter memembers, with support from more than two of current comitters.
List of Contributors
--------------------
* [Full List of Contributors](https://github.com/dmlc/xgboost/graphs/contributors)
- To contributors: please add your name to the list when you submit a patch to the project:)
* [Kailong Chen](https://github.com/kalenhaha)
- Kailong is an early contributor of xgboost, he is creator of ranking objectives in xgboost.
* [Skipper Seabold](https://github.com/jseabold)
- Skipper is the major contributor to the scikit-learn module of xgboost.
* [Zygmunt Zając](https://github.com/zygmuntz)
- Zygmunt is the master behind the early stopping feature frequently used by kagglers.
* [Ajinkya Kale](https://github.com/ajkl)
* [Boliang Chen](https://github.com/cblsjtu)
* [Vadim Khotilovich](https://github.com/khotilov)
* [Yangqing Men](https://github.com/yanqingmen)
- Yangqing is the creator of xgboost java package.
* [Engpeng Yao](https://github.com/yepyao)
* [Giulio](https://github.com/giuliohome)
- Giulio is the creator of windows project of xgboost
* [Jamie Hall](https://github.com/nerdcha)
- Jamie is the initial creator of xgboost sklearn modue.
* [Yen-Ying Lee](https://github.com/white1033)
* [Masaaki Horikoshi](https://github.com/sinhrks)
- Masaaki is the initial creator of xgboost python plotting module.
* [Hongliang Liu](https://github.com/phunterlau)
- Hongliang is the maintainer of xgboost python PyPI package for pip installation.
* [daiyl0320](https://github.com/daiyl0320)
- daiyl0320 contributed patch to xgboost distributed version more robust, and scales stably on TB scale datasets.
* [Huayi Zhang](https://github.com/irachex)
* [Johan Manders](https://github.com/johanmanders)
* [yoori](https://github.com/yoori)
* [Mathias Müller](https://github.com/far0n)
* [Sam Thomson](https://github.com/sammthomson)
* [ganesh-krishnan](https://github.com/ganesh-krishnan)
* [Damien Carol](https://github.com/damiencarol)
* [Alex Bain](https://github.com/convexquad)

View File

@@ -1,9 +1,9 @@
Copyright (c) 2014 by Tianqi Chen and Contributors
Copyright (c) 2016 by Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software

213
Makefile
View File

@@ -1,65 +1,188 @@
export CC = gcc
export CXX = g++
export LDFLAGS= -pthread -lm
export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fPIC -pedantic
ifeq ($(no_omp),1)
CFLAGS += -DDISABLE_OPENMP
else
CFLAGS += -fopenmp
ifndef config
ifneq ("$(wildcard ./config.mk)","")
config = config.mk
else
config = make/config.mk
endif
endif
ifndef DMLC_CORE
DMLC_CORE = dmlc-core
endif
ifndef RABIT
RABIT = rabit
endif
ROOTDIR = $(CURDIR)
ifeq ($(OS), Windows_NT)
UNAME="Windows"
else
UNAME=$(shell uname)
endif
include $(config)
ifeq ($(USE_OPENMP), 0)
export NO_OPENMP = 1
endif
include $(DMLC_CORE)/make/dmlc.mk
# include the plugins
include $(XGB_PLUGINS)
# use customized config file
ifndef CC
export CC = $(if $(shell which gcc-5),gcc-5,gcc)
endif
ifndef CXX
export CXX = $(if $(shell which g++-5),g++-5,g++)
endif
export LDFLAGS= -pthread -lm $(ADD_LDFLAGS) $(DMLC_LDFLAGS) $(PLUGIN_LDFLAGS)
export CFLAGS= -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude $(ADD_CFLAGS) $(PLUGIN_CFLAGS)
CFLAGS += -I$(DMLC_CORE)/include -I$(RABIT)/include
#java include path
export JAVAINCFLAGS = -I${JAVA_HOME}/include -I./java
ifndef LINT_LANG
LINT_LANG= "all"
endif
ifneq ($(UNAME), Windows)
CFLAGS += -fPIC
XGBOOST_DYLIB = lib/libxgboost.so
else
XGBOOST_DYLIB = lib/libxgboost.dll
endif
ifeq ($(UNAME), Linux)
LDFLAGS += -lrt
JAVAINCFLAGS += -I${JAVA_HOME}/include/linux
endif
ifeq ($(UNAME), Darwin)
JAVAINCFLAGS += -I${JAVA_HOME}/include/darwin
endif
ifeq ($(USE_OPENMP), 1)
CFLAGS += -fopenmp
else
CFLAGS += -DDISABLE_OPENMP
endif
# specify tensor path
BIN = xgboost
OBJ = updater.o gbm.o io.o
SLIB = wrapper/libxgboostwrapper.so
.PHONY: clean all lint clean_all doxygen rcpplint pypack Rpack Rbuild Rcheck java pylint
.PHONY: clean all python Rpack
all: $(BIN) $(OBJ) $(SLIB)
all: lib/libxgboost.a $(XGBOOST_DYLIB) xgboost
python: wrapper/libxgboostwrapper.so
# now the wrapper takes in two files. io and wrapper part
wrapper/libxgboostwrapper.so: wrapper/xgboost_wrapper.cpp $(OBJ)
updater.o: src/tree/updater.cpp src/tree/*.hpp src/*.h src/tree/*.h
gbm.o: src/gbm/gbm.cpp src/gbm/*.hpp src/gbm/*.h
io.o: src/io/io.cpp src/io/*.hpp src/utils/*.h src/learner/dmatrix.h src/*.h
xgboost: src/xgboost_main.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h $(OBJ)
wrapper/libxgboostwrapper.so: wrapper/xgboost_wrapper.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h $(OBJ)
$(DMLC_CORE)/libdmlc.a: $(wildcard $(DMLC_CORE)/src/*.cc $(DMLC_CORE)/src/*/*.cc)
+ cd $(DMLC_CORE); $(MAKE) libdmlc.a config=$(ROOTDIR)/$(config); cd $(ROOTDIR)
$(BIN) :
$(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.cpp %.o %.c, $^)
$(RABIT)/lib/$(LIB_RABIT): $(wildcard $(RABIT)/src/*.cc)
+ cd $(RABIT); $(MAKE) lib/$(LIB_RABIT); cd $(ROOTDIR)
$(SLIB) :
$(CXX) $(CFLAGS) -fPIC $(LDFLAGS) -shared -o $@ $(filter %.cpp %.o %.c, $^)
jvm: jvm-packages/lib/libxgboost4j.so
$(OBJ) :
$(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c, $^) )
SRC = $(wildcard src/*.cc src/*/*.cc)
ALL_OBJ = $(patsubst src/%.cc, build/%.o, $(SRC)) $(PLUGIN_OBJS)
AMALGA_OBJ = amalgamation/xgboost-all0.o
LIB_DEP = $(DMLC_CORE)/libdmlc.a $(RABIT)/lib/$(LIB_RABIT)
ALL_DEP = $(filter-out build/cli_main.o, $(ALL_OBJ)) $(LIB_DEP)
CLI_OBJ = build/cli_main.o
install:
cp -f -r $(BIN) $(INSTALL_PATH)
build/%.o: src/%.cc
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -MM -MT build/$*.o $< >build/$*.d
$(CXX) -c $(CFLAGS) -c $< -o $@
build_plugin/%.o: plugin/%.cc
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -MM -MT build_plugin/$*.o $< >build_plugin/$*.d
$(CXX) -c $(CFLAGS) -c $< -o $@
# The should be equivalent to $(ALL_OBJ) except for build/cli_main.o
amalgamation/xgboost-all0.o: amalgamation/xgboost-all0.cc
$(CXX) -c $(CFLAGS) -c $< -o $@
# Equivalent to lib/libxgboost_all.so
lib/libxgboost_all.so: $(AMALGA_OBJ) $(LIB_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
lib/libxgboost.a: $(ALL_DEP)
@mkdir -p $(@D)
ar crv $@ $(filter %.o, $?)
lib/libxgboost.dll lib/libxgboost.so: $(ALL_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -shared -o $@ $(filter %.o %a, $^) $(LDFLAGS)
jvm-packages/lib/libxgboost4j.so: jvm-packages/xgboost4j/src/native/xgboost4j.cpp $(ALL_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(JAVAINCFLAGS) -shared -o $@ $(filter %.cpp %.o %.a, $^) $(LDFLAGS)
xgboost: $(CLI_OBJ) $(ALL_DEP)
$(CXX) $(CFLAGS) -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
rcpplint:
python2 dmlc-core/scripts/lint.py xgboost ${LINT_LANG} R-package/src
lint: rcpplint
python2 dmlc-core/scripts/lint.py xgboost ${LINT_LANG} include src plugin python-package
pylint:
flake8 --ignore E501 python-package
flake8 --ignore E501 tests/python
clean:
$(RM) -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o xgboost
clean_all: clean
cd $(DMLC_CORE); $(MAKE) clean; cd $(ROODIR)
cd $(RABIT); $(MAKE) clean; cd $(ROODIR)
doxygen:
doxygen doc/Doxyfile
# create standalone python tar file.
pypack: ${XGBOOST_DYLIB}
cp ${XGBOOST_DYLIB} python-package/xgboost
cd python-package; tar cf xgboost.tar xgboost; cd ..
# Script to make a clean installable R package.
Rpack:
make clean
$(MAKE) clean_all
rm -rf xgboost xgboost*.tar.gz
cp -r R-package xgboost
rm -rf xgboost/inst/examples/*.buffer
rm -rf xgboost/inst/examples/*.model
rm -rf xgboost/inst/examples/dump*
rm -rf xgboost/src/*.o xgboost/src/*.so xgboost/src/*.dll
rm -rf xgboost/src/*/*.o
rm -rf xgboost/demo/*.model xgboost/demo/*.buffer xgboost/demo/*.txt
rm -rf xgboost/demo/runall.R
cp -r src xgboost/src/src
mkdir xgboost/src/wrapper
cp wrapper/xgboost_wrapper.h xgboost/src/wrapper
cp wrapper/xgboost_wrapper.cpp xgboost/src/wrapper
cp -r include xgboost/src/include
cp -r amalgamation xgboost/src/amalgamation
mkdir -p xgboost/src/rabit
cp -r rabit/include xgboost/src/rabit/include
cp -r rabit/src xgboost/src/rabit/src
rm -rf xgboost/src/rabit/src/*.o
mkdir -p xgboost/src/dmlc-core
cp -r dmlc-core/include xgboost/src/dmlc-core/include
cp -r dmlc-core/src xgboost/src/dmlc-core/src
cp ./LICENSE xgboost
cat R-package/src/Makevars|sed '2s/.*/PKGROOT=./' > xgboost/src/Makevars
cat R-package/src/Makevars.win|sed '2s/.*/PKGROOT=./' > xgboost/src/Makevars.win
R CMD build xgboost
rm -rf xgboost
R CMD check --as-cran xgboost*.tar.gz
cat R-package/src/Makevars|sed '2s/.*/PKGROOT=./' | sed '3s/.*/ENABLE_STD_THREAD=0/' > xgboost/src/Makevars
cp xgboost/src/Makevars xgboost/src/Makevars.win
clean:
$(RM) $(OBJ) $(BIN) $(SLIB) *.o */*.o */*/*.o *~ */*~ */*/*~
Rbuild:
$(MAKE) Rpack
R CMD build --no-build-vignettes xgboost
rm -rf xgboost
Rcheck:
$(MAKE) Rbuild
R CMD check xgboost*.tar.gz
-include build/*.d
-include build/*/*.d
-include build_plugin/*/*.d

104
NEWS.md Normal file
View File

@@ -0,0 +1,104 @@
XGBoost Change Log
==================
This file records the changes in xgboost library in reverse chronological order.
## v0.6 (2016.07.29)
* Version 0.5 is skipped due to major improvements in the core
* Major refactor of core library.
- Goal: more flexible and modular code as a portable library.
- Switch to use of c++11 standard code.
- Random number generator defaults to ```std::mt19937```.
- Share the data loading pipeline and logging module from dmlc-core.
- Enable registry pattern to allow optionally plugin of objective, metric, tree constructor, data loader.
- Future plugin modules can be put into xgboost/plugin and register back to the library.
- Remove most of the raw pointers to smart ptrs, for RAII safety.
* Add official option to approximate algorithm `tree_method` to parameter.
- Change default behavior to switch to prefer faster algorithm.
- User will get a message when approximate algorithm is chosen.
* Change library name to libxgboost.so
* Backward compatiblity
- The binary buffer file is not backward compatible with previous version.
- The model file is backward compatible on 64 bit platforms.
* The model file is compatible between 64/32 bit platforms(not yet tested).
* External memory version and other advanced features will be exposed to R library as well on linux.
- Previously some of the features are blocked due to C++11 and threading limits.
- The windows version is still blocked due to Rtools do not support ```std::thread```.
* rabit and dmlc-core are maintained through git submodule
- Anyone can open PR to update these dependencies now.
* Improvements
- Rabit and xgboost libs are not thread-safe and use thread local PRNGs
- This could fix some of the previous problem which runs xgboost on multiple threads.
* JVM Package
- Enable xgboost4j for java and scala
- XGBoost distributed now runs on Flink and Spark.
* Support model attributes listing for meta data.
- https://github.com/dmlc/xgboost/pull/1198
- https://github.com/dmlc/xgboost/pull/1166
* Support callback API
- https://github.com/dmlc/xgboost/issues/892
- https://github.com/dmlc/xgboost/pull/1211
- https://github.com/dmlc/xgboost/pull/1264
* Support new booster DART(dropout in tree boosting)
- https://github.com/dmlc/xgboost/pull/1220
* Add CMake build system
- https://github.com/dmlc/xgboost/pull/1314
## v0.47 (2016.01.14)
* Changes in R library
- fixed possible problem of poisson regression.
- switched from 0 to NA for missing values.
- exposed access to additional model parameters.
* Changes in Python library
- throws exception instead of crash terminal when a parameter error happens.
- has importance plot and tree plot functions.
- accepts different learning rates for each boosting round.
- allows model training continuation from previously saved model.
- allows early stopping in CV.
- allows feval to return a list of tuples.
- allows eval_metric to handle additional format.
- improved compatibility in sklearn module.
- additional parameters added for sklearn wrapper.
- added pip installation functionality.
- supports more Pandas DataFrame dtypes.
- added best_ntree_limit attribute, in addition to best_score and best_iteration.
* Java api is ready for use
* Added more test cases and continuous integration to make each build more robust.
## v0.4 (2015.05.11)
* Distributed version of xgboost that runs on YARN, scales to billions of examples
* Direct save/load data and model from/to S3 and HDFS
* Feature importance visualization in R module, by Michael Benesty
* Predict leaf index
* Poisson regression for counts data
* Early stopping option in training
* Native save load support in R and python
- xgboost models now can be saved using save/load in R
- xgboost python model is now pickable
* sklearn wrapper is supported in python module
* Experimental External memory version
## v0.3 (2014.09.07)
* Faster tree construction module
- Allows subsample columns during tree construction via ```bst:col_samplebytree=ratio```
* Support for boosting from initial predictions
* Experimental version of LambdaRank
* Linear booster is now parallelized, using parallel coordinated descent.
* Add [Code Guide](src/README.md) for customizing objective function and evaluation
* Add R module
## v0.2x (2014.05.20)
* Python module
* Weighted samples instances
* Initial version of pairwise rank
## v0.1 (2014.03.26)
* Initial release

6
R-package/.Rbuildignore Normal file
View File

@@ -0,0 +1,6 @@
\.o$
\.so$
\.dll$
^.*\.Rproj$
^\.Rproj\.user$
README.md

View File

@@ -1,24 +1,39 @@
Package: xgboost
Type: Package
Title: eXtreme Gradient Boosting
Version: 0.3-2
Date: 2014-08-23
Author: Tianqi Chen <tianqi.tchen@gmail.com>, Tong He <hetong007@gmail.com>
Title: Extreme Gradient Boosting
Version: 0.6-0
Date: 2015-08-01
Author: Tianqi Chen <tianqi.tchen@gmail.com>, Tong He <hetong007@gmail.com>,
Michael Benesty <michael@benesty.fr>, Vadim Khotilovich <khotilovich@gmail.com>,
Yuan Tang <terrytangyuan@gmail.com>
Maintainer: Tong He <hetong007@gmail.com>
Description: This package is a R wrapper of xgboost, which is short for eXtreme
Gradient Boosting. It is an efficient and scalable implementation of
gradient boosting framework. The package includes efficient linear model
solver and tree learning algorithms. The package can automatically do
parallel computation with OpenMP, and it can be more than 10 times faster
than existing gradient boosting packages such as gbm. It supports various
objective functions, including regression, classification and ranking. The
package is made to be extensible, so that users are also allowed to define
Description: Extreme Gradient Boosting, which is an efficient implementation
of gradient boosting framework. This package is its R interface. The package
includes efficient linear model solver and tree learning algorithms. The package
can automatically do parallel computation on a single machine which could be
more than 10 times faster than existing gradient boosting packages. It supports
various objective functions, including regression, classification and ranking.
The package is made to be extensible, so that users are also allowed to define
their own objectives easily.
License: Apache License (== 2.0) | file LICENSE
URL: https://github.com/tqchen/xgboost
BugReports: https://github.com/tqchen/xgboost/issues
URL: https://github.com/dmlc/xgboost
BugReports: https://github.com/dmlc/xgboost/issues
VignetteBuilder: knitr
Suggests:
knitr,
rmarkdown,
ggplot2 (>= 1.0.1),
DiagrammeR (>= 0.8.1),
Ckmeans.1d.dp (>= 3.3.1),
vcd (>= 1.3),
testthat,
igraph (>= 1.0.1)
Depends:
R (>= 2.10)
Imports:
Matrix (>= 1.1-0),
methods
methods,
data.table (>= 1.9.6),
magrittr (>= 1.5),
stringi (>= 0.5.2)
RoxygenNote: 5.0.1

View File

@@ -1,17 +1,71 @@
# Generated by roxygen2 (4.0.1): do not edit by hand
# Generated by roxygen2: do not edit by hand
S3method("[",xgb.DMatrix)
S3method("dimnames<-",xgb.DMatrix)
S3method(dim,xgb.DMatrix)
S3method(dimnames,xgb.DMatrix)
S3method(getinfo,xgb.DMatrix)
S3method(predict,xgb.Booster)
S3method(predict,xgb.Booster.handle)
S3method(print,xgb.Booster)
S3method(print,xgb.DMatrix)
S3method(print,xgb.cv.synchronous)
S3method(setinfo,xgb.DMatrix)
S3method(slice,xgb.DMatrix)
export("xgb.attr<-")
export("xgb.attributes<-")
export("xgb.parameters<-")
export(cb.cv.predict)
export(cb.early.stop)
export(cb.evaluation.log)
export(cb.print.evaluation)
export(cb.reset.parameters)
export(cb.save.model)
export(getinfo)
export(setinfo)
export(slice)
export(xgb.DMatrix)
export(xgb.DMatrix.save)
export(xgb.attr)
export(xgb.attributes)
export(xgb.create.features)
export(xgb.cv)
export(xgb.dump)
export(xgb.ggplot.deepness)
export(xgb.ggplot.importance)
export(xgb.importance)
export(xgb.load)
export(xgb.model.dt.tree)
export(xgb.plot.deepness)
export(xgb.plot.importance)
export(xgb.plot.multi.trees)
export(xgb.plot.tree)
export(xgb.save)
export(xgb.save.raw)
export(xgb.train)
export(xgboost)
exportMethods(predict)
import(methods)
importClassesFrom(Matrix,dgCMatrix)
importClassesFrom(Matrix,dgeMatrix)
importFrom(Matrix,cBind)
importFrom(Matrix,colSums)
importFrom(Matrix,sparse.model.matrix)
importFrom(Matrix,sparseVector)
importFrom(data.table,":=")
importFrom(data.table,as.data.table)
importFrom(data.table,data.table)
importFrom(data.table,rbindlist)
importFrom(data.table,setkey)
importFrom(data.table,setkeyv)
importFrom(data.table,setnames)
importFrom(magrittr,"%>%")
importFrom(stats,predict)
importFrom(stringi,stri_detect_regex)
importFrom(stringi,stri_match_first_regex)
importFrom(stringi,stri_replace_all_regex)
importFrom(stringi,stri_replace_first_regex)
importFrom(stringi,stri_split_regex)
importFrom(utils,object.size)
importFrom(utils,str)
importFrom(utils,tail)
useDynLib(xgboost)

608
R-package/R/callbacks.R Normal file
View File

@@ -0,0 +1,608 @@
#' Callback closures for booster training.
#'
#' These are used to perform various service tasks either during boosting iterations or at the end.
#' This approach helps to modularize many of such tasks without bloating the main training methods,
#' and it offers .
#'
#' @details
#' By default, a callback function is run after each boosting iteration.
#' An R-attribute \code{is_pre_iteration} could be set for a callback to define a pre-iteration function.
#'
#' When a callback function has \code{finalize} parameter, its finalizer part will also be run after
#' the boosting is completed.
#'
#' WARNING: side-effects!!! Be aware that these callback functions access and modify things in
#' the environment from which they are called from, which is a fairly uncommon thing to do in R.
#'
#' To write a custom callback closure, make sure you first understand the main concepts about R envoronments.
#' Check either R documentation on \code{\link[base]{environment}} or the
#' \href{http://adv-r.had.co.nz/Environments.html}{Environments chapter} from the "Advanced R"
#' book by Hadley Wickham. Further, the best option is to read the code of some of the existing callbacks -
#' choose ones that do something similar to what you want to achieve. Also, you would need to get familiar
#' with the objects available inside of the \code{xgb.train} and \code{xgb.cv} internal environments.
#'
#' @seealso
#' \code{\link{cb.print.evaluation}},
#' \code{\link{cb.evaluation.log}},
#' \code{\link{cb.reset.parameters}},
#' \code{\link{cb.early.stop}},
#' \code{\link{cb.save.model}},
#' \code{\link{cb.cv.predict}},
#' \code{\link{xgb.train}},
#' \code{\link{xgb.cv}}
#'
#' @name callbacks
NULL
#
# Callbacks -------------------------------------------------------------------
#
#' Callback closure for printing the result of evaluation
#'
#' @param period results would be printed every number of periods
#'
#' @details
#' The callback function prints the result of evaluation at every \code{period} iterations.
#' The initial and the last iteration's evaluations are always printed.
#'
#' Callback function expects the following values to be set in its calling frame:
#' \code{bst_evaluation} (also \code{bst_evaluation_err} when available),
#' \code{iteration},
#' \code{begin_iteration},
#' \code{end_iteration}.
#'
#' @seealso
#' \code{\link{callbacks}}
#'
#' @export
cb.print.evaluation <- function(period=1) {
callback <- function(env = parent.frame()) {
if (length(env$bst_evaluation) == 0 ||
period == 0 ||
NVL(env$rank, 0) != 0 )
return()
i <- env$iteration
if ((i-1) %% period == 0 ||
i == env$begin_iteration ||
i == env$end_iteration) {
msg <- format.eval.string(i, env$bst_evaluation, env$bst_evaluation_err)
cat(msg, '\n')
}
}
attr(callback, 'call') <- match.call()
attr(callback, 'name') <- 'cb.print.evaluation'
callback
}
#' Callback closure for logging the evaluation history
#'
#' @details
#' This callback function appends the current iteration evaluation results \code{bst_evaluation}
#' available in the calling parent frame to the \code{evaluation_log} list in a calling frame.
#'
#' The finalizer callback (called with \code{finalize = TURE} in the end) converts
#' the \code{evaluation_log} list into a final data.table.
#'
#' The iteration evaluation result \code{bst_evaluation} must be a named numeric vector.
#'
#' Note: in the column names of the final data.table, the dash '-' character is replaced with
#' the underscore '_' in order to make the column names more like regular R identifiers.
#'
#' Callback function expects the following values to be set in its calling frame:
#' \code{evaluation_log},
#' \code{bst_evaluation},
#' \code{iteration}.
#'
#' @seealso
#' \code{\link{callbacks}}
#'
#' @export
cb.evaluation.log <- function() {
mnames <- NULL
init <- function(env) {
if (!is.list(env$evaluation_log))
stop("'evaluation_log' has to be a list")
mnames <<- names(env$bst_evaluation)
if (is.null(mnames) || any(mnames == ""))
stop("bst_evaluation must have non-empty names")
mnames <<- gsub('-', '_', names(env$bst_evaluation))
if(!is.null(env$bst_evaluation_err))
mnames <<- c(paste0(mnames, '_mean'), paste0(mnames, '_std'))
}
finalizer <- function(env) {
env$evaluation_log <- as.data.table(t(simplify2array(env$evaluation_log)))
setnames(env$evaluation_log, c('iter', mnames))
if(!is.null(env$bst_evaluation_err)) {
# rearrange col order from _mean,_mean,...,_std,_std,...
# to be _mean,_std,_mean,_std,...
len <- length(mnames)
means <- mnames[1:(len/2)]
stds <- mnames[(len/2 + 1):len]
cnames <- numeric(len)
cnames[c(TRUE, FALSE)] <- means
cnames[c(FALSE, TRUE)] <- stds
env$evaluation_log <- env$evaluation_log[, c('iter', cnames), with=FALSE]
}
}
callback <- function(env = parent.frame(), finalize = FALSE) {
if (is.null(mnames))
init(env)
if (finalize)
return(finalizer(env))
ev <- env$bst_evaluation
if(!is.null(env$bst_evaluation_err))
ev <- c(ev, env$bst_evaluation_err)
env$evaluation_log <- c(env$evaluation_log,
list(c(iter = env$iteration, ev)))
}
attr(callback, 'call') <- match.call()
attr(callback, 'name') <- 'cb.evaluation.log'
callback
}
#' Callback closure for restetting the booster's parameters at each iteration.
#'
#' @param new_params a list where each element corresponds to a parameter that needs to be reset.
#' Each element's value must be either a vector of values of length \code{nrounds}
#' to be set at each iteration,
#' or a function of two parameters \code{learning_rates(iteration, nrounds)}
#' which returns a new parameter value by using the current iteration number
#' and the total number of boosting rounds.
#'
#' @details
#' This is a "pre-iteration" callback function used to reset booster's parameters
#' at the beginning of each iteration.
#'
#' Note that when training is resumed from some previous model, and a function is used to
#' reset a parameter value, the \code{nround} argument in this function would be the
#' the number of boosting rounds in the current training.
#'
#' Callback function expects the following values to be set in its calling frame:
#' \code{bst} or \code{bst_folds},
#' \code{iteration},
#' \code{begin_iteration},
#' \code{end_iteration}.
#'
#' @seealso
#' \code{\link{callbacks}}
#'
#' @export
cb.reset.parameters <- function(new_params) {
if (typeof(new_params) != "list")
stop("'new_params' must be a list")
pnames <- gsub("\\.", "_", names(new_params))
nrounds <- NULL
# run some checks in the begining
init <- function(env) {
nrounds <<- env$end_iteration - env$begin_iteration + 1
if (is.null(env$bst) && is.null(env$bst_folds))
stop("Parent frame has neither 'bst' nor 'bst_folds'")
# Some parameters are not allowed to be changed,
# since changing them would simply wreck some chaos
not_allowed <- pnames %in%
c('num_class', 'num_output_group', 'size_leaf_vector', 'updater_seq')
if (any(not_allowed))
stop('Parameters ', paste(pnames[not_allowed]), " cannot be changed during boosting.")
for (n in pnames) {
p <- new_params[[n]]
if (is.function(p)) {
if (length(formals(p)) != 2)
stop("Parameter '", n, "' is a function but not of two arguments")
} else if (is.numeric(p) || is.character(p)) {
if (length(p) != nrounds)
stop("Length of '", n, "' has to be equal to 'nrounds'")
} else {
stop("Parameter '", n, "' is not a function or a vector")
}
}
}
callback <- function(env = parent.frame()) {
if (is.null(nrounds))
init(env)
i <- env$iteration
pars <- lapply(new_params, function(p) {
if (is.function(p))
return(p(i, nrounds))
p[i]
})
if (!is.null(env$bst)) {
xgb.parameters(env$bst$handle) <- pars
} else {
for (fd in env$bst_folds)
xgb.parameters(fd$bst$handle) <- pars
}
}
attr(callback, 'is_pre_iteration') <- TRUE
attr(callback, 'call') <- match.call()
attr(callback, 'name') <- 'cb.reset.parameters'
callback
}
#' Callback closure to activate the early stopping.
#'
#' @param stopping_rounds The number of rounds with no improvement in
#' the evaluation metric in order to stop the training.
#' @param maximize whether to maximize the evaluation metric
#' @param metric_name the name of an evaluation column to use as a criteria for early
#' stopping. If not set, the last column would be used.
#' Let's say the test data in \code{watchlist} was labelled as \code{dtest},
#' and one wants to use the AUC in test data for early stopping regardless of where
#' it is in the \code{watchlist}, then one of the following would need to be set:
#' \code{metric_name='dtest-auc'} or \code{metric_name='dtest_auc'}.
#' All dash '-' characters in metric names are considered equivalent to '_'.
#' @param verbose whether to print the early stopping information.
#'
#' @details
#' This callback function determines the condition for early stopping
#' by setting the \code{stop_condition = TRUE} flag in its calling frame.
#'
#' The following additional fields are assigned to the model's R object:
#' \itemize{
#' \item \code{best_score} the evaluation score at the best iteration
#' \item \code{best_iteration} at which boosting iteration the best score has occurred (1-based index)
#' \item \code{best_ntreelimit} to use with the \code{ntreelimit} parameter in \code{predict}.
#' It differs from \code{best_iteration} in multiclass or random forest settings.
#' }
#'
#' The Same values are also stored as xgb-attributes:
#' \itemize{
#' \item \code{best_iteration} is stored as a 0-based iteration index (for interoperability of binary models)
#' \item \code{best_msg} message string is also stored.
#' }
#'
#' At least one data element is required in the evaluation watchlist for early stopping to work.
#'
#' Callback function expects the following values to be set in its calling frame:
#' \code{stop_condition},
#' \code{bst_evaluation},
#' \code{rank},
#' \code{bst} (or \code{bst_folds} and \code{basket}),
#' \code{iteration},
#' \code{begin_iteration},
#' \code{end_iteration},
#' \code{num_parallel_tree}.
#'
#' @seealso
#' \code{\link{callbacks}},
#' \code{\link{xgb.attr}}
#'
#' @export
cb.early.stop <- function(stopping_rounds, maximize=FALSE,
metric_name=NULL, verbose=TRUE) {
# state variables
best_iteration <- -1
best_ntreelimit <- -1
best_score <- Inf
best_msg <- NULL
metric_idx <- 1
init <- function(env) {
if (length(env$bst_evaluation) == 0)
stop("For early stopping, watchlist must have at least one element")
eval_names <- gsub('-', '_', names(env$bst_evaluation))
if (!is.null(metric_name)) {
metric_idx <<- which(gsub('-', '_', metric_name) == eval_names)
if (length(metric_idx) == 0)
stop("'metric_name' for early stopping is not one of the following:\n",
paste(eval_names, collapse=' '), '\n')
}
if (is.null(metric_name) &&
length(env$bst_evaluation) > 1) {
metric_idx <<- length(eval_names)
if (verbose)
cat('Multiple eval metrics are present. Will use ',
eval_names[metric_idx], ' for early stopping.\n', sep = '')
}
metric_name <<- eval_names[metric_idx]
# maximixe is usually NULL when not set in xgb.train and built-in metrics
if (is.null(maximize))
maximize <<- ifelse(grepl('(_auc|_map|_ndcg)', metric_name), TRUE, FALSE)
if (verbose && NVL(env$rank, 0) == 0)
cat("Will train until ", metric_name, " hasn't improved in ",
stopping_rounds, " rounds.\n\n", sep = '')
best_iteration <<- 1
if (maximize) best_score <<- -Inf
env$stop_condition <- FALSE
if (!is.null(env$bst)) {
if (class(env$bst) != 'xgb.Booster')
stop("'bst' in the parent frame must be an 'xgb.Booster'")
if (!is.null(best_score <- xgb.attr(env$bst$handle, 'best_score'))) {
best_score <<- as.numeric(best_score)
best_iteration <<- as.numeric(xgb.attr(env$bst$handle, 'best_iteration')) + 1
best_msg <<- as.numeric(xgb.attr(env$bst$handle, 'best_msg'))
} else {
xgb.attributes(env$bst$handle) <- list(best_iteration = best_iteration - 1,
best_score = best_score)
}
} else if (is.null(env$bst_folds) || is.null(env$basket)) {
stop("Parent frame has neither 'bst' nor ('bst_folds' and 'basket')")
}
}
finalizer <- function(env) {
if (!is.null(env$bst)) {
attr_best_score = as.numeric(xgb.attr(env$bst$handle, 'best_score'))
if (best_score != attr_best_score)
stop("Inconsistent 'best_score' values between the closure state: ", best_score,
" and the xgb.attr: ", attr_best_score)
env$bst$best_iteration = best_iteration
env$bst$best_ntreelimit = best_ntreelimit
env$bst$best_score = best_score
} else {
env$basket$best_iteration <- best_iteration
env$basket$best_ntreelimit <- best_ntreelimit
}
}
callback <- function(env = parent.frame(), finalize = FALSE) {
if (best_iteration < 0)
init(env)
if (finalize)
return(finalizer(env))
i <- env$iteration
score = env$bst_evaluation[metric_idx]
if (( maximize && score > best_score) ||
(!maximize && score < best_score)) {
best_msg <<- format.eval.string(i, env$bst_evaluation, env$bst_evaluation_err)
best_score <<- score
best_iteration <<- i
best_ntreelimit <<- best_iteration * env$num_parallel_tree
# save the property to attributes, so they will occur in checkpoint
if (!is.null(env$bst)) {
xgb.attributes(env$bst) <- list(
best_iteration = best_iteration - 1, # convert to 0-based index
best_score = best_score,
best_msg = best_msg,
best_ntreelimit = best_ntreelimit)
}
} else if (i - best_iteration >= stopping_rounds) {
env$stop_condition <- TRUE
env$end_iteration <- i
if (verbose && NVL(env$rank, 0) == 0)
cat("Stopping. Best iteration:\n", best_msg, "\n\n", sep = '')
}
}
attr(callback, 'call') <- match.call()
attr(callback, 'name') <- 'cb.early.stop'
callback
}
#' Callback closure for saving a model file.
#'
#' @param save_period save the model to disk after every
#' \code{save_period} iterations; 0 means save the model at the end.
#' @param save_name the name or path for the saved model file.
#' It can contain a \code{\link[base]{sprintf}} formatting specifier
#' to include the integer iteration number in the file name.
#' E.g., with \code{save_name} = 'xgboost_%04d.model',
#' the file saved at iteration 50 would be named "xgboost_0050.model".
#'
#' @details
#' This callback function allows to save an xgb-model file, either periodically after each \code{save_period}'s or at the end.
#'
#' Callback function expects the following values to be set in its calling frame:
#' \code{bst},
#' \code{iteration},
#' \code{begin_iteration},
#' \code{end_iteration}.
#'
#' @seealso
#' \code{\link{callbacks}}
#'
#' @export
cb.save.model <- function(save_period = 0, save_name = "xgboost.model") {
if (save_period < 0)
stop("'save_period' cannot be negative")
callback <- function(env = parent.frame()) {
if (is.null(env$bst))
stop("'save_model' callback requires the 'bst' booster object in its calling frame")
if ((save_period > 0 && (env$iteration - env$begin_iteration) %% save_period == 0) ||
(save_period == 0 && env$iteration == env$end_iteration))
xgb.save(env$bst, sprintf(save_name, env$iteration))
}
attr(callback, 'call') <- match.call()
attr(callback, 'name') <- 'cb.save.model'
callback
}
#' Callback closure for returning cross-validation based predictions.
#'
#' @param save_models a flag for whether to save the folds' models.
#'
#' @details
#' This callback function saves predictions for all of the test folds,
#' and also allows to save the folds' models.
#'
#' It is a "finalizer" callback and it uses early stopping information whenever it is available,
#' thus it must be run after the early stopping callback if the early stopping is used.
#'
#' Callback function expects the following values to be set in its calling frame:
#' \code{bst_folds},
#' \code{basket},
#' \code{data},
#' \code{end_iteration},
#' \code{num_parallel_tree},
#' \code{num_class}.
#'
#' @return
#' Predictions are returned inside of the \code{pred} element, which is either a vector or a matrix,
#' depending on the number of prediction outputs per data row. The order of predictions corresponds
#' to the order of rows in the original dataset. Note that when a custom \code{folds} list is
#' provided in \code{xgb.cv}, the predictions would only be returned properly when this list is a
#' non-overlapping list of k sets of indices, as in a standard k-fold CV. The predictions would not be
#' meaningful when user-profided folds have overlapping indices as in, e.g., random sampling splits.
#' When some of the indices in the training dataset are not included into user-provided \code{folds},
#' their prediction value would be \code{NA}.
#'
#' @seealso
#' \code{\link{callbacks}}
#'
#' @export
cb.cv.predict <- function(save_models = FALSE) {
finalizer <- function(env) {
if (is.null(env$basket) || is.null(env$bst_folds))
stop("'cb.cv.predict' callback requires 'basket' and 'bst_folds' lists in its calling frame")
N <- nrow(env$data)
pred <-
if (env$num_class > 1) {
matrix(NA_real_, N, env$num_class)
} else {
rep(NA_real_, N)
}
ntreelimit <- NVL(env$basket$best_ntreelimit,
env$end_iteration * env$num_parallel_tree)
for (fd in env$bst_folds) {
pr <- predict(fd$bst, fd$watchlist[[2]], ntreelimit = ntreelimit, reshape = TRUE)
if (is.matrix(pred)) {
pred[fd$index,] <- pr
} else {
pred[fd$index] <- pr
}
}
env$basket$pred <- pred
if (save_models) {
env$basket$models <- lapply(env$bst_folds, function(fd) {
xgb.attr(fd$bst, 'niter') <- env$end_iteration - 1
xgb.Booster.check(xgb.handleToBooster(fd$bst), saveraw = TRUE)
})
}
}
callback <- function(env = parent.frame(), finalize = FALSE) {
if (finalize)
return(finalizer(env))
}
attr(callback, 'call') <- match.call()
attr(callback, 'name') <- 'cb.cv.predict'
callback
}
#
# Internal utility functions for callbacks ------------------------------------
#
# Format the evaluation metric string
format.eval.string <- function(iter, eval_res, eval_err=NULL) {
if (length(eval_res) == 0)
stop('no evaluation results')
enames <- names(eval_res)
if (is.null(enames))
stop('evaluation results must have names')
iter <- sprintf('[%d]\t', iter)
if (!is.null(eval_err)) {
if (length(eval_res) != length(eval_err))
stop('eval_res & eval_err lengths mismatch')
res <- paste0(sprintf("%s:%f+%f", enames, eval_res, eval_err), collapse='\t')
} else {
res <- paste0(sprintf("%s:%f", enames, eval_res), collapse='\t')
}
return(paste0(iter, res))
}
# Extract callback names from the list of callbacks
callback.names <- function(cb_list) {
unlist(lapply(cb_list, function(x) attr(x, 'name')))
}
# Extract callback calls from the list of callbacks
callback.calls <- function(cb_list) {
unlist(lapply(cb_list, function(x) attr(x, 'call')))
}
# Add a callback cb to the list and make sure that
# cb.early.stop and cb.cv.predict are at the end of the list
# with cb.cv.predict being the last (when present)
add.cb <- function(cb_list, cb) {
cb_list <- c(cb_list, cb)
names(cb_list) <- callback.names(cb_list)
if ('cb.early.stop' %in% names(cb_list)) {
cb_list <- c(cb_list, cb_list['cb.early.stop'])
# this removes only the first one
cb_list['cb.early.stop'] <- NULL
}
if ('cb.cv.predict' %in% names(cb_list)) {
cb_list <- c(cb_list, cb_list['cb.cv.predict'])
cb_list['cb.cv.predict'] <- NULL
}
cb_list
}
# Sort callbacks list into categories
categorize.callbacks <- function(cb_list) {
list(
pre_iter = Filter(function(x) {
pre <- attr(x, 'is_pre_iteration')
!is.null(pre) && pre
}, cb_list),
post_iter = Filter(function(x) {
pre <- attr(x, 'is_pre_iteration')
is.null(pre) || !pre
}, cb_list),
finalize = Filter(function(x) {
'finalize' %in% names(formals(x))
}, cb_list)
)
}
# Check whether all callback functions with names given by 'query_names' are present in the 'cb_list'.
has.callbacks <- function(cb_list, query_names) {
if (length(cb_list) < length(query_names))
return(FALSE)
if (!is.list(cb_list) ||
any(sapply(cb_list, class) != 'function')) {
stop('`cb_list`` must be a list of callback functions')
}
cb_names <- callback.names(cb_list)
if (!is.character(cb_names) ||
length(cb_names) != length(cb_list) ||
any(cb_names == "")) {
stop('All callbacks in the `cb_list` must have a non-empty `name` attribute')
}
if (!is.character(query_names) ||
length(query_names) == 0 ||
any(query_names == "")) {
stop('query_names must be a non-empty vector of non-empty character names')
}
return(all(query_names %in% cb_names))
}

View File

@@ -1,41 +0,0 @@
setClass('xgb.DMatrix')
#' Get information of an xgb.DMatrix object
#'
#' Get information of an xgb.DMatrix object
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#' labels <- getinfo(dtrain, 'label')
#' setinfo(dtrain, 'label', 1-labels)
#' labels2 <- getinfo(dtrain, 'label')
#' stopifnot(all(labels2 == 1-labels))
#' @rdname getinfo
#' @export
#'
getinfo <- function(object, ...){
UseMethod("getinfo")
}
#' @param object Object of class "xgb.DMatrix"
#' @param name the name of the field to get
#' @param ... other parameters
#' @rdname getinfo
#' @method getinfo xgb.DMatrix
setMethod("getinfo", signature = "xgb.DMatrix",
definition = function(object, name) {
if (typeof(name) != "character") {
stop("xgb.getinfo: name must be character")
}
if (class(object) != "xgb.DMatrix") {
stop("xgb.setinfo: first argument dtrain must be xgb.DMatrix")
}
if (name != "label" && name != "weight" && name != "base_margin") {
stop(paste("xgb.getinfo: unknown info name", name))
}
ret <- .Call("XGDMatrixGetInfo_R", object, name, PACKAGE = "xgboost")
return(ret)
})

View File

@@ -1,42 +0,0 @@
setClass("xgb.Booster")
#' Predict method for eXtreme Gradient Boosting model
#'
#' Predicted values based on xgboost model object.
#'
#' @param object Object of class "xgb.Boost"
#' @param newdata takes \code{matrix}, \code{dgCMatrix}, local data file or
#' \code{xgb.DMatrix}.
#' @param outputmargin whether the prediction should be shown in the original
#' value of sum of functions, when outputmargin=TRUE, the prediction is
#' untransformed margin value. In logistic regression, outputmargin=T will
#' output value before logistic transformation.
#' @param ntreelimit limit number of trees used in prediction, this parameter is
#' only valid for gbtree, but not for gblinear. set it to be value bigger
#' than 0. It will use all trees by default.
#' @examples
#' data(agaricus.train, package='xgboost')
#' data(agaricus.test, package='xgboost')
#' train <- agaricus.train
#' test <- agaricus.test
#' bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
#' eta = 1, nround = 2,objective = "binary:logistic")
#' pred <- predict(bst, test$data)
#' @export
#'
setMethod("predict", signature = "xgb.Booster",
definition = function(object, newdata, outputmargin = FALSE, ntreelimit = NULL) {
if (class(newdata) != "xgb.DMatrix") {
newdata <- xgb.DMatrix(newdata)
}
if (is.null(ntreelimit)) {
ntreelimit <- 0
} else {
if (ntreelimit < 1){
stop("predict: ntreelimit must be equal to or greater than 1")
}
}
ret <- .Call("XGBoosterPredict_R", object, newdata, as.integer(outputmargin), as.integer(ntreelimit), PACKAGE = "xgboost")
return(ret)
})

View File

@@ -1,29 +0,0 @@
#' Set information of an xgb.DMatrix object
#'
#' Set information of an xgb.DMatrix object
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#' labels <- getinfo(dtrain, 'label')
#' setinfo(dtrain, 'label', 1-labels)
#' labels2 <- getinfo(dtrain, 'label')
#' stopifnot(all(labels2 == 1-labels))
#' @rdname setinfo
#' @export
#'
setinfo <- function(object, ...){
UseMethod("setinfo")
}
#' @param object Object of class "xgb.DMatrix"
#' @param name the name of the field to get
#' @param info the specific field of information to set
#' @param ... other parameters
#' @rdname setinfo
#' @method setinfo xgb.DMatrix
setMethod("setinfo", signature = "xgb.DMatrix",
definition = function(object, name, info) {
xgb.setinfo(object, name, info)
})

View File

@@ -1,33 +0,0 @@
setClass('xgb.DMatrix')
#' Get a new DMatrix containing the specified rows of
#' orginal xgb.DMatrix object
#'
#' Get a new DMatrix containing the specified rows of
#' orginal xgb.DMatrix object
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#' dsub <- slice(dtrain, 1:3)
#' @rdname slice
#' @export
#'
slice <- function(object, ...){
UseMethod("slice")
}
#' @param object Object of class "xgb.DMatrix"
#' @param idxset a integer vector of indices of rows needed
#' @param ... other parameters
#' @rdname slice
#' @method slice xgb.DMatrix
setMethod("slice", signature = "xgb.DMatrix",
definition = function(object, idxset, ...) {
if (class(object) != "xgb.DMatrix") {
stop("slice: first argument dtrain must be xgb.DMatrix")
}
ret <- .Call("XGDMatrixSliceDMatrix_R", object, idxset, PACKAGE = "xgboost")
return(structure(ret, class = "xgb.DMatrix"))
})

View File

@@ -1,214 +1,329 @@
#' @importClassesFrom Matrix dgCMatrix dgeMatrix
#' @import methods
#
# This file is for the low level reuseable utility functions
# that are not supposed to be visibe to a user.
#
# depends on matrix
.onLoad <- function(libname, pkgname) {
library.dynam("xgboost", pkgname, libname)
}
.onUnload <- function(libpath) {
library.dynam.unload("xgboost", libpath)
#
# General helper utilities ----------------------------------------------------
#
# SQL-style NVL shortcut.
NVL <- function(x, val) {
if (is.null(x))
return(val)
if (is.vector(x)) {
x[is.na(x)] <- val
return(x)
}
if (typeof(x) == 'closure')
return(x)
stop('x of unsupported for NVL type')
}
# set information into dmatrix, this mutate dmatrix
xgb.setinfo <- function(dmat, name, info) {
if (class(dmat) != "xgb.DMatrix") {
stop("xgb.setinfo: first argument dtrain must be xgb.DMatrix")
#
# Low-level functions for boosting --------------------------------------------
#
# Merges booster params with whatever is provided in ...
# plus runs some checks
check.booster.params <- function(params, ...) {
if (typeof(params) != "list")
stop("params must be a list")
# in R interface, allow for '.' instead of '_' in parameter names
names(params) <- gsub("\\.", "_", names(params))
# merge parameters from the params and the dots-expansion
dot_params <- list(...)
names(dot_params) <- gsub("\\.", "_", names(dot_params))
if (length(intersect(names(params),
names(dot_params))) > 0)
stop("Same parameters in 'params' and in the call are not allowed. Please check your 'params' list.")
params <- c(params, dot_params)
# providing a parameter multiple times only makes sense for 'eval_metric'
name_freqs <- table(names(params))
multi_names <- setdiff(names(name_freqs[name_freqs > 1]), 'eval_metric')
if (length(multi_names) > 0) {
warning("The following parameters were provided multiple times:\n\t",
paste(multi_names, collapse=', '), "\n Only the last value for each of them will be used.\n")
# While xgboost itself would choose the last value for a multi-parameter,
# will do some clean-up here b/c multi-parameters could be used further in R code, and R would
# pick the 1st (not the last) value when multiple elements with the same name are present in a list.
for (n in multi_names) {
del_idx <- which(n == names(params))
del_idx <- del_idx[-length(del_idx)]
params[[del_idx]] <- NULL
}
}
if (name == "label") {
.Call("XGDMatrixSetInfo_R", dmat, name, as.numeric(info),
PACKAGE = "xgboost")
return(TRUE)
# for multiclass, expect num_class to be set
if (typeof(params[['objective']]) == "character" &&
substr(NVL(params[['objective']], 'x'), 1, 6) == 'multi:') {
if (as.numeric(NVL(params[['num_class']], 0)) < 2)
stop("'num_class' > 1 parameter must be set for multiclass classification")
}
if (name == "weight") {
.Call("XGDMatrixSetInfo_R", dmat, name, as.numeric(info),
PACKAGE = "xgboost")
return(TRUE)
}
if (name == "base_margin") {
.Call("XGDMatrixSetInfo_R", dmat, name, as.numeric(info),
PACKAGE = "xgboost")
return(TRUE)
}
if (name == "group") {
.Call("XGDMatrixSetInfo_R", dmat, name, as.integer(info),
PACKAGE = "xgboost")
return(TRUE)
}
stop(paste("xgb.setinfo: unknown info name", name))
return(FALSE)
return(params)
}
# construct a Booster from cachelist
xgb.Booster <- function(params = list(), cachelist = list(), modelfile = NULL) {
if (typeof(cachelist) != "list") {
stop("xgb.Booster: only accepts list of DMatrix as cachelist")
# Performs some checks related to custom objective function.
# WARNING: has side-effects and can modify 'params' and 'obj' in its calling frame
check.custom.obj <- function(env = parent.frame()) {
if (!is.null(env$params[['objective']]) && !is.null(env$obj))
stop("Setting objectives in 'params' and 'obj' at the same time is not allowed")
if (!is.null(env$obj) && typeof(env$obj) != 'closure')
stop("'obj' must be a function")
# handle the case when custom objective function was provided through params
if (!is.null(env$params[['objective']]) &&
typeof(env$params$objective) == 'closure') {
env$obj <- env$params$objective
p <- env$params
p$objective <- NULL
env$params <- p
}
for (dm in cachelist) {
if (class(dm) != "xgb.DMatrix") {
stop("xgb.Booster: only accepts list of DMatrix as cachelist")
}
}
handle <- .Call("XGBoosterCreate_R", cachelist, PACKAGE = "xgboost")
if (length(params) != 0) {
for (i in 1:length(params)) {
p <- params[i]
.Call("XGBoosterSetParam_R", handle, gsub("\\.", "_", names(p)), as.character(p),
PACKAGE = "xgboost")
}
}
if (!is.null(modelfile)) {
if (typeof(modelfile) != "character") {
stop("xgb.Booster: modelfile must be character")
}
.Call("XGBoosterLoadModel_R", handle, modelfile, PACKAGE = "xgboost")
}
return(structure(handle, class = "xgb.Booster"))
}
## ----the following are low level iteratively function, not needed if
## you do not want to use them ---------------------------------------
# get dmatrix from data, label
xgb.get.DMatrix <- function(data, label = NULL) {
inClass <- class(data)
if (inClass == "dgCMatrix" || inClass == "matrix") {
if (is.null(label)) {
stop("xgboost: need label when data is a matrix")
}
dtrain <- xgb.DMatrix(data, label = label)
} else {
if (!is.null(label)) {
warning("xgboost: label will be ignored.")
}
if (inClass == "character") {
dtrain <- xgb.DMatrix(data)
} else if (inClass == "xgb.DMatrix") {
dtrain <- data
} else {
stop("xgboost: Invalid input of data")
}
# Performs some checks related to custom evaluation function.
# WARNING: has side-effects and can modify 'params' and 'feval' in its calling frame
check.custom.eval <- function(env = parent.frame()) {
if (!is.null(env$params[['eval_metric']]) && !is.null(env$feval))
stop("Setting evaluation metrics in 'params' and 'feval' at the same time is not allowed")
if (!is.null(env$feval) && typeof(env$feval) != 'closure')
stop("'feval' must be a function")
if (!is.null(env$feval) && is.null(env$maximize))
stop("Please set 'maximize' to indicate whether the metric needs to be maximized or not")
# handle a situation when custom eval function was provided through params
if (!is.null(env$params[['eval_metric']]) &&
typeof(env$params$eval_metric) == 'closure') {
env$feval <- env$params$eval_metric
p <- env$params
p[ which(names(p) == 'eval_metric') ] <- NULL
env$params <- p
}
return (dtrain)
}
xgb.numrow <- function(dmat) {
nrow <- .Call("XGDMatrixNumRow_R", dmat, PACKAGE="xgboost")
return(nrow)
}
# iteratively update booster with customized statistics
xgb.iter.boost <- function(booster, dtrain, gpair) {
if (class(booster) != "xgb.Booster") {
stop("xgb.iter.update: first argument must be type xgb.Booster")
}
if (class(dtrain) != "xgb.DMatrix") {
stop("xgb.iter.update: second argument must be type xgb.DMatrix")
}
.Call("XGBoosterBoostOneIter_R", booster, dtrain, gpair$grad, gpair$hess,
PACKAGE = "xgboost")
return(TRUE)
}
# iteratively update booster with dtrain
# Update booster with dtrain for an iteration
xgb.iter.update <- function(booster, dtrain, iter, obj = NULL) {
if (class(booster) != "xgb.Booster") {
stop("xgb.iter.update: first argument must be type xgb.Booster")
if (class(booster) != "xgb.Booster.handle") {
stop("first argument type must be xgb.Booster.handle")
}
if (class(dtrain) != "xgb.DMatrix") {
stop("xgb.iter.update: second argument must be type xgb.DMatrix")
stop("second argument type must be xgb.DMatrix")
}
if (is.null(obj)) {
.Call("XGBoosterUpdateOneIter_R", booster, as.integer(iter), dtrain,
.Call("XGBoosterUpdateOneIter_R", booster, as.integer(iter), dtrain,
PACKAGE = "xgboost")
} else {
pred <- predict(booster, dtrain)
gpair <- obj(pred, dtrain)
succ <- xgb.iter.boost(booster, dtrain, gpair)
.Call("XGBoosterBoostOneIter_R", booster, dtrain, gpair$grad, gpair$hess, PACKAGE = "xgboost")
}
return(TRUE)
}
# iteratively evaluate one iteration
# Evaluate one iteration.
# Returns a named vector of evaluation metrics
# with the names in a 'datasetname-metricname' format.
xgb.iter.eval <- function(booster, watchlist, iter, feval = NULL) {
if (class(booster) != "xgb.Booster") {
stop("xgb.eval: first argument must be type xgb.Booster")
if (class(booster) != "xgb.Booster.handle")
stop("first argument type must be xgb.Booster.handle")
if (length(watchlist) == 0)
return(NULL)
evnames <- names(watchlist)
if (is.null(feval)) {
msg <- .Call("XGBoosterEvalOneIter_R", booster, as.integer(iter), watchlist,
as.list(evnames), PACKAGE = "xgboost")
msg <- stri_split_regex(msg, '(\\s+|:|\\s+)')[[1]][-1]
res <- as.numeric(msg[c(FALSE,TRUE)]) # even indices are the values
names(res) <- msg[c(TRUE,FALSE)] # odds are the names
} else {
res <- sapply(seq_along(watchlist), function(j) {
w <- watchlist[[j]]
preds <- predict(booster, w) # predict using all trees
eval_res <- feval(preds, w)
out <- eval_res$value
names(out) <- paste0(evnames[j], "-", eval_res$metric)
out
})
}
if (typeof(watchlist) != "list") {
stop("xgb.eval: only accepts list of DMatrix as watchlist")
return(res)
}
#
# Helper functions for cross validation ---------------------------------------
#
# Generates random (stratified if needed) CV folds
generate.cv.folds <- function(nfold, nrows, stratified, label, params) {
# cannot do it for rank
if (exists('objective', where=params) &&
is.character(params$objective) &&
strtrim(params$objective, 5) == 'rank:') {
stop("\n\tAutomatic generation of CV-folds is not implemented for ranking!\n",
"\tConsider providing pre-computed CV-folds through the 'folds=' parameter.\n")
}
for (w in watchlist) {
if (class(w) != "xgb.DMatrix") {
stop("xgb.eval: watch list can only contain xgb.DMatrix")
}
}
if (length(watchlist) != 0) {
if (is.null(feval)) {
evnames <- list()
for (i in 1:length(watchlist)) {
w <- watchlist[i]
if (length(names(w)) == 0) {
stop("xgb.eval: name tag must be presented for every elements in watchlist")
}
evnames <- append(evnames, names(w))
}
msg <- .Call("XGBoosterEvalOneIter_R", booster, as.integer(iter), watchlist,
evnames, PACKAGE = "xgboost")
# shuffle
rnd_idx <- sample(1:nrows)
if (stratified &&
length(label) == length(rnd_idx)) {
y <- label[rnd_idx]
# WARNING: some heuristic logic is employed to identify classification setting!
# - For classification, need to convert y labels to factor before making the folds,
# and then do stratification by factor levels.
# - For regression, leave y numeric and do stratification by quantiles.
if (exists('objective', where=params) &&
is.character(params$objective)) {
# If 'objective' provided in params, assume that y is a classification label
# unless objective is reg:linear
if (params$objective != 'reg:linear')
y <- factor(y)
} else {
msg <- paste("[", iter, "]", sep="")
for (j in 1:length(watchlist)) {
w <- watchlist[j]
if (length(names(w)) == 0) {
stop("xgb.eval: name tag must be presented for every elements in watchlist")
}
ret <- feval(predict(booster, w[[1]]), w[[1]])
msg <- paste(msg, "\t", names(w), "-", ret$metric, ":", ret$value, sep="")
}
# If no 'objective' given in params, it means that user either wants to use
# the default 'reg:linear' objective or has provided a custom obj function.
# Here, assume classification setting when y has 5 or less unique values:
if (length(unique(y)) <= 5)
y <- factor(y)
}
folds <- xgb.createFolds(y, nfold)
} else {
# make simple non-stratified folds
kstep <- length(rnd_idx) %/% nfold
folds <- list()
for (i in 1:(nfold - 1)) {
folds[[i]] <- rnd_idx[1:kstep]
rnd_idx <- rnd_idx[-(1:kstep)]
}
folds[[nfold]] <- rnd_idx
}
return(folds)
}
# Creates CV folds stratified by the values of y.
# It was borrowed from caret::createFolds and simplified
# by always returning an unnamed list of fold indices.
xgb.createFolds <- function(y, k = 10)
{
if (is.numeric(y)) {
## Group the numeric data based on their magnitudes
## and sample within those groups.
## When the number of samples is low, we may have
## issues further slicing the numeric data into
## groups. The number of groups will depend on the
## ratio of the number of folds to the sample size.
## At most, we will use quantiles. If the sample
## is too small, we just do regular unstratified
## CV
cuts <- floor(length(y) / k)
if (cuts < 2) cuts <- 2
if (cuts > 5) cuts <- 5
y <- cut(y,
unique(stats::quantile(y, probs = seq(0, 1, length = cuts))),
include.lowest = TRUE)
}
if (k < length(y)) {
## reset levels so that the possible levels and
## the levels in the vector are the same
y <- factor(as.character(y))
numInClass <- table(y)
foldVector <- vector(mode = "integer", length(y))
## For each class, balance the fold allocation as far
## as possible, then resample the remainder.
## The final assignment of folds is also randomized.
for (i in 1:length(numInClass)) {
## create a vector of integers from 1:k as many times as possible without
## going over the number of samples in the class. Note that if the number
## of samples in a class is less than k, nothing is producd here.
seqVector <- rep(1:k, numInClass[i] %/% k)
## add enough random integers to get length(seqVector) == numInClass[i]
if (numInClass[i] %% k > 0) seqVector <- c(seqVector, sample(1:k, numInClass[i] %% k))
## shuffle the integers for fold assignment and assign to this classes's data
foldVector[which(y == dimnames(numInClass)$y[i])] <- sample(seqVector)
}
} else {
msg <- ""
foldVector <- seq(along = y)
}
return(msg)
}
#------------------------------------------
# helper functions for cross validation
out <- split(seq(along = y), foldVector)
names(out) <- NULL
out
}
#
xgb.cv.mknfold <- function(dall, nfold, param) {
randidx <- sample(1 : xgb.numrow(dall))
kstep <- length(randidx) / nfold
idset <- list()
for (i in 1:nfold) {
idset[[i]] <- randidx[ ((i-1) * kstep + 1) : min(i * kstep, length(randidx)) ]
}
ret <- list()
for (k in 1:nfold) {
dtest <- slice(dall, idset[[k]])
didx = c()
for (i in 1:nfold) {
if (i != k) {
didx <- append(didx, idset[[i]])
}
# Deprectaion notice utilities ------------------------------------------------
#
#' Deprecation notices.
#'
#' At this time, some of the parameter names were changed in order to make the code style more uniform.
#' The deprecated parameters would be removed in the next release.
#'
#' To see all the current deprecated and new parameters, check the \code{xgboost:::depr_par_lut} table.
#'
#' A deprecation warning is shown when any of the deprecated parameters is used in a call.
#' An additional warning is shown when there was a partial match to a deprecated parameter
#' (as R is able to partially match parameter names).
#'
#' @name xgboost-deprecated
NULL
# Lookup table for the deprecated parameters bookkeeping
depr_par_lut <- matrix(c(
'print.every.n', 'print_every_n',
'early.stop.round', 'early_stopping_rounds',
'training.data', 'data',
'with.stats', 'with_stats',
'numberOfClusters', 'n_clusters',
'features.keep', 'features_keep',
'plot.height','plot_height',
'plot.width','plot_width',
'dummy', 'DUMMY'
), ncol=2, byrow = TRUE)
colnames(depr_par_lut) <- c('old', 'new')
# Checks the dot-parameters for deprecated names
# (including partial matching), gives a deprecation warning,
# and sets new parameters to the old parameters' values within its parent frame.
# WARNING: has side-effects
check.deprecation <- function(..., env = parent.frame()) {
pars <- list(...)
# exact and partial matches
all_match <- pmatch(names(pars), depr_par_lut[,1])
# indices of matched pars' names
idx_pars <- which(!is.na(all_match))
if (length(idx_pars) == 0) return()
# indices of matched LUT rows
idx_lut <- all_match[idx_pars]
# which of idx_lut were the exact matches?
ex_match <- depr_par_lut[idx_lut,1] %in% names(pars)
for (i in seq_along(idx_pars)) {
pars_par <- names(pars)[idx_pars[i]]
old_par <- depr_par_lut[idx_lut[i], 1]
new_par <- depr_par_lut[idx_lut[i], 2]
if (!ex_match[i]) {
warning("'", pars_par, "' was partially matched to '", old_par,"'")
}
.Deprecated(new_par, old=old_par, package = 'xgboost')
if (new_par != 'NULL') {
eval(parse(text = paste(new_par, '<-', pars[[pars_par]])), envir = env)
}
dtrain <- slice(dall, didx)
bst <- xgb.Booster(param, list(dtrain, dtest))
watchlist = list(train=dtrain, test=dtest)
ret[[k]] <- list(dtrain=dtrain, booster=bst, watchlist=watchlist)
}
return (ret)
}
xgb.cv.aggcv <- function(res, showsd = TRUE) {
header <- res[[1]]
ret <- header[1]
for (i in 2:length(header)) {
kv <- strsplit(header[i], ":")[[1]]
ret <- paste(ret, "\t", kv[1], ":", sep="")
stats <- c()
stats[1] <- as.numeric(kv[2])
for (j in 2:length(res)) {
tkv <- strsplit(res[[j]][i], ":")[[1]]
stats[j] <- as.numeric(tkv[2])
}
ret <- paste(ret, sprintf("%f", mean(stats)), sep="")
if (showsd) {
ret <- paste(ret, sprintf("+%f", sd(stats)), sep="")
}
}
return (ret)
}

486
R-package/R/xgb.Booster.R Normal file
View File

@@ -0,0 +1,486 @@
# Construct a Booster from cachelist
# internal utility function
xgb.Booster <- function(params = list(), cachelist = list(), modelfile = NULL) {
if (typeof(cachelist) != "list" ||
any(sapply(cachelist, class) != 'xgb.DMatrix')) {
stop("xgb.Booster only accepts list of DMatrix as cachelist")
}
handle <- .Call("XGBoosterCreate_R", cachelist, PACKAGE = "xgboost")
if (!is.null(modelfile)) {
if (typeof(modelfile) == "character") {
.Call("XGBoosterLoadModel_R", handle, modelfile, PACKAGE = "xgboost")
} else if (typeof(modelfile) == "raw") {
.Call("XGBoosterLoadModelFromRaw_R", handle, modelfile, PACKAGE = "xgboost")
} else if (class(modelfile) == "xgb.Booster") {
modelfile <- xgb.Booster.check(modelfile, saveraw=TRUE)
.Call("XGBoosterLoadModelFromRaw_R", handle, modelfile$raw, PACKAGE = "xgboost")
} else {
stop("modelfile must be either character filename, or raw booster dump, or xgb.Booster object")
}
}
class(handle) <- "xgb.Booster.handle"
if (length(params) > 0) {
xgb.parameters(handle) <- params
}
return(handle)
}
# Convert xgb.Booster.handle to xgb.Booster
# internal utility function
xgb.handleToBooster <- function(handle, raw = NULL) {
bst <- list(handle = handle, raw = raw)
class(bst) <- "xgb.Booster"
return(bst)
}
# Return a verified to be valid handle out of either xgb.Booster.handle or xgb.Booster
# internal utility function
xgb.get.handle <- function(object) {
handle <- switch(class(object)[1],
xgb.Booster = object$handle,
xgb.Booster.handle = object,
stop("argument must be of either xgb.Booster or xgb.Booster.handle class")
)
if (is.null(handle) || .Call("XGCheckNullPtr_R", handle, PACKAGE="xgboost")) {
stop("invalid xgb.Booster.handle")
}
handle
}
# Check whether an xgb.Booster object is complete
# internal utility function
xgb.Booster.check <- function(bst, saveraw = TRUE) {
if (class(bst) != "xgb.Booster")
stop("argument type must be xgb.Booster")
isnull <- is.null(bst$handle)
if (!isnull) {
isnull <- .Call("XGCheckNullPtr_R", bst$handle, PACKAGE="xgboost")
}
if (isnull) {
bst$handle <- xgb.Booster(modelfile = bst$raw)
} else {
if (is.null(bst$raw) && saveraw)
bst$raw <- xgb.save.raw(bst$handle)
}
return(bst)
}
#' Predict method for eXtreme Gradient Boosting model
#'
#' Predicted values based on either xgboost model or model handle object.
#'
#' @param object Object of class \code{xgb.Booster} or \code{xgb.Booster.handle}
#' @param newdata takes \code{matrix}, \code{dgCMatrix}, local data file or \code{xgb.DMatrix}.
#' @param missing Missing is only used when input is dense matrix. Pick a float value that represents
#' missing values in data (e.g., sometimes 0 or some other extreme value is used).
#' @param outputmargin whether the prediction should be returned in the for of original untransformed
#' sum of predictions from boosting iterations' results. E.g., setting \code{outputmargin=TRUE} for
#' logistic regression would result in predictions for log-odds instead of probabilities.
#' @param ntreelimit limit the number of model's trees or boosting iterations used in prediction (see Details).
#' It will use all the trees by default (\code{NULL} value).
#' @param predleaf whether predict leaf index instead.
#' @param reshape whether to reshape the vector of predictions to a matrix form when there are several
#' prediction outputs per case. This option has no effect when \code{predleaf = TRUE}.
#' @param ... Parameters passed to \code{predict.xgb.Booster}
#'
#' @details
#' Note that \code{ntreelimit} is not necesserily equal to the number of boosting iterations
#' and it is not necesserily equal to the number of trees in a model.
#' E.g., in a random forest-like model, \code{ntreelimit} would limit the number of trees.
#' But for multiclass classification, there are multiple trees per iteration,
#' but \code{ntreelimit} limits the number of boosting iterations.
#'
#' Also note that \code{ntreelimit} would currently do nothing for predictions from gblinear,
#' since gblinear doesn't keep its boosting history.
#'
#' One possible practical applications of the \code{predleaf} option is to use the model
#' as a generator of new features which capture non-linearity and interactions,
#' e.g., as implemented in \code{\link{xgb.create.features}}.
#'
#' @return
#' For regression or binary classification, it returns a vector of length \code{nrows(newdata)}.
#' For multiclass classification, either a \code{num_class * nrows(newdata)} vector or
#' a \code{(nrows(newdata), num_class)} dimension matrix is returned, depending on
#' the \code{reshape} value.
#'
#' When \code{predleaf = TRUE}, the output is a matrix object with the
#' number of columns corresponding to the number of trees.
#'
#' @seealso
#' \code{\link{xgb.train}}.
#'
#' @examples
#' ## binary classification:
#'
#' data(agaricus.train, package='xgboost')
#' data(agaricus.test, package='xgboost')
#' train <- agaricus.train
#' test <- agaricus.test
#'
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
#' # use all trees by default
#' pred <- predict(bst, test$data)
#' # use only the 1st tree
#' pred <- predict(bst, test$data, ntreelimit = 1)
#'
#'
#' ## multiclass classification in iris dataset:
#'
#' lb <- as.numeric(iris$Species) - 1
#' num_class <- 3
#' set.seed(11)
#' bst <- xgboost(data = as.matrix(iris[, -5]), label = lb,
#' max_depth = 4, eta = 0.5, nthread = 2, nrounds = 10, subsample = 0.5,
#' objective = "multi:softprob", num_class = num_class)
#' # predict for softmax returns num_class probability numbers per case:
#' pred <- predict(bst, as.matrix(iris[, -5]))
#' str(pred)
#' # reshape it to a num_class-columns matrix
#' pred <- matrix(pred, ncol=num_class, byrow=TRUE)
#' # convert the probabilities to softmax labels
#' pred_labels <- max.col(pred) - 1
#' # the following should result in the same error as seen in the last iteration
#' sum(pred_labels != lb)/length(lb)
#'
#' # compare that to the predictions from softmax:
#' set.seed(11)
#' bst <- xgboost(data = as.matrix(iris[, -5]), label = lb,
#' max_depth = 4, eta = 0.5, nthread = 2, nrounds = 10, subsample = 0.5,
#' objective = "multi:softmax", num_class = num_class)
#' pred <- predict(bst, as.matrix(iris[, -5]))
#' str(pred)
#' all.equal(pred, pred_labels)
#' # prediction from using only 5 iterations should result
#' # in the same error as seen in iteration 5:
#' pred5 <- predict(bst, as.matrix(iris[, -5]), ntreelimit=5)
#' sum(pred5 != lb)/length(lb)
#'
#'
#' ## random forest-like model of 25 trees for binary classification:
#'
#' set.seed(11)
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 5,
#' nthread = 2, nrounds = 1, objective = "binary:logistic",
#' num_parallel_tree = 25, subsample = 0.6, colsample_bytree = 0.1)
#' # Inspect the prediction error vs number of trees:
#' lb <- test$label
#' dtest <- xgb.DMatrix(test$data, label=lb)
#' err <- sapply(1:25, function(n) {
#' pred <- predict(bst, dtest, ntreelimit=n)
#' sum((pred > 0.5) != lb)/length(lb)
#' })
#' plot(err, type='l', ylim=c(0,0.1), xlab='#trees')
#'
#' @rdname predict.xgb.Booster
#' @export
predict.xgb.Booster <- function(object, newdata, missing = NA,
outputmargin = FALSE, ntreelimit = NULL, predleaf = FALSE, reshape = FALSE, ...) {
object <- xgb.Booster.check(object, saveraw = FALSE)
if (class(newdata) != "xgb.DMatrix")
newdata <- xgb.DMatrix(newdata, missing = missing)
if (is.null(ntreelimit))
ntreelimit <- NVL(object$best_ntreelimit, 0)
if (ntreelimit < 0)
stop("ntreelimit cannot be negative")
option <- 0L + 1L * as.logical(outputmargin) + 2L * as.logical(predleaf)
ret <- .Call("XGBoosterPredict_R", object$handle, newdata, option[1],
as.integer(ntreelimit), PACKAGE = "xgboost")
if (length(ret) %% nrow(newdata) != 0)
stop("prediction length ", length(ret)," is not multiple of nrows(newdata) ", nrow(newdata))
npred_per_case <- length(ret) / nrow(newdata)
if (predleaf){
len <- nrow(newdata)
ret <- if (length(ret) == len) {
matrix(ret, ncol = 1)
} else {
t(matrix(ret, ncol = len))
}
} else if (reshape && npred_per_case > 1) {
ret <- matrix(ret, ncol = length(ret) / nrow(newdata), byrow = TRUE)
}
return(ret)
}
#' @rdname predict.xgb.Booster
#' @export
predict.xgb.Booster.handle <- function(object, ...) {
bst <- xgb.handleToBooster(object)
ret <- predict(bst, ...)
return(ret)
}
#' Accessors for serializable attributes of a model.
#'
#' These methods allow to manipulate the key-value attribute strings of an xgboost model.
#'
#' @param object Object of class \code{xgb.Booster} or \code{xgb.Booster.handle}.
#' @param name a non-empty character string specifying which attribute is to be accessed.
#' @param value a value of an attribute for \code{xgb.attr<-}; for \code{xgb.attributes<-}
#' it's a list (or an object coercible to a list) with the names of attributes to set
#' and the elements corresponding to attribute values.
#' Non-character values are converted to character.
#' When attribute value is not a scalar, only the first index is used.
#' Use \code{NULL} to remove an attribute.
#'
#' @details
#' The primary purpose of xgboost model attributes is to store some meta-data about the model.
#' Note that they are a separate concept from the object attributes in R.
#' Specifically, they refer to key-value strings that can be attached to an xgboost model,
#' stored together with the model's binary representation, and accessed later
#' (from R or any other interface).
#' In contrast, any R-attribute assigned to an R-object of \code{xgb.Booster} class
#' would not be saved by \code{xgb.save} because an xgboost model is an external memory object
#' and its serialization is handled extrnally.
#' Also, setting an attribute that has the same name as one of xgboost's parameters wouldn't
#' change the value of that parameter for a model.
#' Use \code{\link{xgb.parameters<-}} to set or change model parameters.
#'
#' The attribute setters would usually work more efficiently for \code{xgb.Booster.handle}
#' than for \code{xgb.Booster}, since only just a handle (pointer) would need to be copied.
#' That would only matter if attributes need to be set many times.
#' Note, however, that when feeding a handle of an \code{xgb.Booster} object to the attribute setters,
#' the raw model cache of an \code{xgb.Booster} object would not be automatically updated,
#' and it would be user's responsibility to call \code{xgb.save.raw} to update it.
#'
#' The \code{xgb.attributes<-} setter either updates the existing or adds one or several attributes,
#' but it doesn't delete the other existing attributes.
#'
#' @return
#' \code{xgb.attr} returns either a string value of an attribute
#' or \code{NULL} if an attribute wasn't stored in a model.
#'
#' \code{xgb.attributes} returns a list of all attribute stored in a model
#' or \code{NULL} if a model has no stored attributes.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#'
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
#'
#' xgb.attr(bst, "my_attribute") <- "my attribute value"
#' print(xgb.attr(bst, "my_attribute"))
#' xgb.attributes(bst) <- list(a = 123, b = "abc")
#'
#' xgb.save(bst, 'xgb.model')
#' bst1 <- xgb.load('xgb.model')
#' print(xgb.attr(bst1, "my_attribute"))
#' print(xgb.attributes(bst1))
#'
#' # deletion:
#' xgb.attr(bst1, "my_attribute") <- NULL
#' print(xgb.attributes(bst1))
#' xgb.attributes(bst1) <- list(a = NULL, b = NULL)
#' print(xgb.attributes(bst1))
#'
#' @rdname xgb.attr
#' @export
xgb.attr <- function(object, name) {
if (is.null(name) || nchar(as.character(name[1])) == 0) stop("invalid attribute name")
handle <- xgb.get.handle(object)
.Call("XGBoosterGetAttr_R", handle, as.character(name[1]), PACKAGE="xgboost")
}
#' @rdname xgb.attr
#' @export
`xgb.attr<-` <- function(object, name, value) {
if (is.null(name) || nchar(as.character(name[1])) == 0) stop("invalid attribute name")
handle <- xgb.get.handle(object)
if (!is.null(value)) {
# Coerce the elements to be scalar strings.
# Q: should we warn user about non-scalar elements?
value <- as.character(value[1])
}
.Call("XGBoosterSetAttr_R", handle, as.character(name[1]), value, PACKAGE="xgboost")
if (is(object, 'xgb.Booster') && !is.null(object$raw)) {
object$raw <- xgb.save.raw(object$handle)
}
object
}
#' @rdname xgb.attr
#' @export
xgb.attributes <- function(object) {
handle <- xgb.get.handle(object)
attr_names <- .Call("XGBoosterGetAttrNames_R", handle, PACKAGE="xgboost")
if (is.null(attr_names)) return(NULL)
res <- lapply(attr_names, function(x) {
.Call("XGBoosterGetAttr_R", handle, x, PACKAGE="xgboost")
})
names(res) <- attr_names
res
}
#' @rdname xgb.attr
#' @export
`xgb.attributes<-` <- function(object, value) {
a <- as.list(value)
if (is.null(names(a)) || any(nchar(names(a)) == 0)) {
stop("attribute names cannot be empty strings")
}
# Coerce the elements to be scalar strings.
# Q: should we warn a user about non-scalar elements?
a <- lapply(a, function(x) {
if (is.null(x)) return(NULL)
as.character(x[1])
})
handle <- xgb.get.handle(object)
for (i in seq_along(a)) {
.Call("XGBoosterSetAttr_R", handle, names(a[i]), a[[i]], PACKAGE="xgboost")
}
if (is(object, 'xgb.Booster') && !is.null(object$raw)) {
object$raw <- xgb.save.raw(object$handle)
}
object
}
#' Accessors for model parameters.
#'
#' Only the setter for xgboost parameters is currently implemented.
#'
#' @param object Object of class \code{xgb.Booster} or \code{xgb.Booster.handle}.
#' @param value a list (or an object coercible to a list) with the names of parameters to set
#' and the elements corresponding to parameter values.
#'
#' @details
#' Note that the setter would usually work more efficiently for \code{xgb.Booster.handle}
#' than for \code{xgb.Booster}, since only just a handle would need to be copied.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#'
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
#'
#' xgb.parameters(bst) <- list(eta = 0.1)
#'
#' @rdname xgb.parameters
#' @export
`xgb.parameters<-` <- function(object, value) {
if (length(value) == 0) return(object)
p <- as.list(value)
if (is.null(names(p)) || any(nchar(names(p)) == 0)) {
stop("parameter names cannot be empty strings")
}
names(p) <- gsub("\\.", "_", names(p))
p <- lapply(p, function(x) as.character(x)[1])
handle <- xgb.get.handle(object)
for (i in seq_along(p)) {
.Call("XGBoosterSetParam_R", handle, names(p[i]), p[[i]], PACKAGE = "xgboost")
}
if (is(object, 'xgb.Booster') && !is.null(object$raw)) {
object$raw <- xgb.save.raw(object$handle)
}
object
}
# Extract # of trees in a model
# TODO: either add a getter to C-interface, or simply set an 'ntree' attribute after each iteration
# internal utility function
xgb.ntree <- function(bst) {
length(grep('^booster', xgb.dump(bst)))
}
#' Print xgb.Booster
#'
#' Print information about xgb.Booster.
#'
#' @param x an xgb.Booster object
#' @param verbose whether to print detailed data (e.g., attribute values)
#' @param ... not currently used
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
#' attr(bst, 'myattr') <- 'memo'
#'
#' print(bst)
#' print(bst, verbose=TRUE)
#'
#' @method print xgb.Booster
#' @export
print.xgb.Booster <- function(x, verbose=FALSE, ...) {
cat('##### xgb.Booster\n')
if (is.null(x$handle) || .Call("XGCheckNullPtr_R", x$handle, PACKAGE="xgboost")) {
cat("handle is invalid\n")
return(x)
}
cat('raw: ')
if (!is.null(x$raw)) {
cat(format(object.size(x$raw), units="auto"), '\n')
} else {
cat('NULL\n')
}
if (!is.null(x$call)) {
cat('call:\n ')
print(x$call)
}
if (!is.null(x$params)) {
cat('params (as set within xgb.train):\n')
cat( ' ',
paste(names(x$params),
paste0('"', unlist(x$params), '"'),
sep=' = ', collapse=', '), '\n', sep='')
}
# TODO: need an interface to access all the xgboosts parameters
attrs <- xgb.attributes(x)
if (length(attrs) > 0) {
cat('xgb.attributes:\n')
if (verbose) {
cat( paste(paste0(' ',names(attrs)),
paste0('"', unlist(attrs), '"'),
sep=' = ', collapse='\n'), '\n', sep='')
} else {
cat(' ', paste(names(attrs), collapse=', '), '\n', sep='')
}
}
if (!is.null(x$callbacks) && length(x$callbacks) > 0) {
cat('callbacks:\n')
lapply(callback.calls(x$callbacks), function(x) {
cat(' ')
print(x)
})
}
cat('niter: ', x$niter, '\n', sep='')
# TODO: uncomment when faster xgb.ntree is implemented
#cat('ntree: ', xgb.ntree(x), '\n', sep='')
for (n in setdiff(names(x), c('handle', 'raw', 'call', 'params', 'callbacks','evaluation_log','niter'))) {
if (is.atomic(x[[n]])) {
cat(n, ': ', x[[n]], '\n', sep='')
} else {
cat(n, ':\n\t', sep='')
print(x[[n]])
}
}
if (!is.null(x$evaluation_log)) {
cat('evaluation_log:\n')
print(x$evaluation_log, row.names = FALSE, topn = 2)
}
invisible(x)
}

View File

@@ -1,12 +1,12 @@
#' Contruct xgb.DMatrix object
#'
#' Contruct xgb.DMatrix object from dense matrix, sparse matrix or local file.
#' Contruct xgb.DMatrix object from dense matrix, sparse matrix
#' or local file (that was created previously by saving an \code{xgb.DMatrix}).
#'
#' @param data a \code{matrix} object, a \code{dgCMatrix} object or a character
#' indicating the data file.
#' @param data a \code{matrix} object, a \code{dgCMatrix} object or a character representing a filename
#' @param info a list of information of the xgb.DMatrix object
#' @param missing Missing is only used when input is dense matrix, pick a float
# value that represents missing value. Sometime a data use 0 or other extreme value to represents missing values.
#' value that represents missing value. Sometime a data use 0 or other extreme value to represents missing values.
#
#' @param ... other information to pass to \code{info}.
#'
@@ -17,29 +17,351 @@
#' xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
#' dtrain <- xgb.DMatrix('xgb.DMatrix.data')
#' @export
#'
xgb.DMatrix <- function(data, info = list(), missing = 0, ...) {
xgb.DMatrix <- function(data, info = list(), missing = NA, ...) {
cnames <- NULL
if (typeof(data) == "character") {
handle <- .Call("XGDMatrixCreateFromFile_R", data, as.integer(FALSE),
handle <- .Call("XGDMatrixCreateFromFile_R", data, as.integer(FALSE),
PACKAGE = "xgboost")
} else if (is.matrix(data)) {
handle <- .Call("XGDMatrixCreateFromMat_R", data, missing,
handle <- .Call("XGDMatrixCreateFromMat_R", data, missing,
PACKAGE = "xgboost")
cnames <- colnames(data)
} else if (class(data) == "dgCMatrix") {
handle <- .Call("XGDMatrixCreateFromCSC_R", data@p, data@i, data@x,
handle <- .Call("XGDMatrixCreateFromCSC_R", data@p, data@i, data@x,
PACKAGE = "xgboost")
cnames <- colnames(data)
} else {
stop(paste("xgb.DMatrix: does not support to construct from ",
stop(paste("xgb.DMatrix: does not support to construct from ",
typeof(data)))
}
dmat <- structure(handle, class = "xgb.DMatrix")
dmat <- handle
attributes(dmat) <- list(.Dimnames = list(NULL, cnames), class = "xgb.DMatrix")
#dmat <- list(handle = handle, colnames = cnames)
#attr(dmat, 'class') <- "xgb.DMatrix"
info <- append(info, list(...))
if (length(info) == 0)
if (length(info) == 0)
return(dmat)
for (i in 1:length(info)) {
p <- info[i]
xgb.setinfo(dmat, names(p), p[[1]])
setinfo(dmat, names(p), p[[1]])
}
return(dmat)
}
}
# get dmatrix from data, label
# internal helper method
xgb.get.DMatrix <- function(data, label = NULL, missing = NA, weight = NULL) {
inClass <- class(data)
if ("dgCMatrix" %in% inClass || "matrix" %in% inClass ) {
if (is.null(label)) {
stop("xgboost: need label when data is a matrix")
}
dtrain <- xgb.DMatrix(data, label = label, missing = missing)
if (!is.null(weight)){
setinfo(dtrain, "weight", weight)
}
} else {
if (!is.null(label)) {
warning("xgboost: label will be ignored.")
}
if (inClass == "character") {
dtrain <- xgb.DMatrix(data)
} else if (inClass == "xgb.DMatrix") {
dtrain <- data
} else if (inClass == "data.frame") {
stop("xgboost only support numerical matrix input,
use 'data.matrix' to transform the data.")
} else {
stop("xgboost: Invalid input of data")
}
}
return (dtrain)
}
#' Dimensions of xgb.DMatrix
#'
#' Returns a vector of numbers of rows and of columns in an \code{xgb.DMatrix}.
#' @param x Object of class \code{xgb.DMatrix}
#'
#' @details
#' Note: since \code{nrow} and \code{ncol} internally use \code{dim}, they can also
#' be directly used with an \code{xgb.DMatrix} object.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#'
#' stopifnot(nrow(dtrain) == nrow(train$data))
#' stopifnot(ncol(dtrain) == ncol(train$data))
#' stopifnot(all(dim(dtrain) == dim(train$data)))
#'
#' @export
dim.xgb.DMatrix <- function(x) {
c(.Call("XGDMatrixNumRow_R", x, PACKAGE="xgboost"),
.Call("XGDMatrixNumCol_R", x, PACKAGE="xgboost"))
}
#' Handling of column names of \code{xgb.DMatrix}
#'
#' Only column names are supported for \code{xgb.DMatrix}, thus setting of
#' row names would have no effect and returnten row names would be NULL.
#'
#' @param x object of class \code{xgb.DMatrix}
#' @param value a list of two elements: the first one is ignored
#' and the second one is column names
#'
#' @details
#' Generic \code{dimnames} methods are used by \code{colnames}.
#' Since row names are irrelevant, it is recommended to use \code{colnames} directly.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#' dimnames(dtrain)
#' colnames(dtrain)
#' colnames(dtrain) <- make.names(1:ncol(train$data))
#' print(dtrain, verbose=TRUE)
#'
#' @rdname dimnames.xgb.DMatrix
#' @export
dimnames.xgb.DMatrix <- function(x) {
attr(x, '.Dimnames')
}
#' @rdname dimnames.xgb.DMatrix
#' @export
`dimnames<-.xgb.DMatrix` <- function(x, value) {
if (!is.list(value) || length(value) != 2L)
stop("invalid 'dimnames' given: must be a list of two elements")
if (!is.null(value[[1L]]))
stop("xgb.DMatrix does not have rownames")
if (is.null(value[[2]])) {
attr(x, '.Dimnames') <- NULL
return(x)
}
if (ncol(x) != length(value[[2]]))
stop("can't assign ", length(value[[2]]), " colnames to a ",
ncol(x), " column xgb.DMatrix")
attr(x, '.Dimnames') <- value
x
}
#' Get information of an xgb.DMatrix object
#'
#' Get information of an xgb.DMatrix object
#' @param object Object of class \code{xgb.DMatrix}
#' @param name the name of the information field to get (see details)
#' @param ... other parameters
#'
#' @details
#' The \code{name} field can be one of the following:
#'
#' \itemize{
#' \item \code{label}: label Xgboost learn from ;
#' \item \code{weight}: to do a weight rescale ;
#' \item \code{base_margin}: base margin is the base prediction Xgboost will boost from ;
#' \item \code{nrow}: number of rows of the \code{xgb.DMatrix}.
#' }
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#'
#' labels <- getinfo(dtrain, 'label')
#' setinfo(dtrain, 'label', 1-labels)
#'
#' labels2 <- getinfo(dtrain, 'label')
#' stopifnot(all(labels2 == 1-labels))
#' @rdname getinfo
#' @export
getinfo <- function(object, ...) UseMethod("getinfo")
#' @rdname getinfo
#' @export
getinfo.xgb.DMatrix <- function(object, name, ...) {
if (typeof(name) != "character" ||
length(name) != 1 ||
!name %in% c('label', 'weight', 'base_margin', 'nrow')) {
stop("getinfo: name must one of the following\n",
" 'label', 'weight', 'base_margin', 'nrow'")
}
if (name != "nrow"){
ret <- .Call("XGDMatrixGetInfo_R", object, name, PACKAGE = "xgboost")
} else {
ret <- nrow(object)
}
if (length(ret) == 0) return(NULL)
return(ret)
}
#' Set information of an xgb.DMatrix object
#'
#' Set information of an xgb.DMatrix object
#'
#' @param object Object of class "xgb.DMatrix"
#' @param name the name of the field to get
#' @param info the specific field of information to set
#' @param ... other parameters
#'
#' @details
#' The \code{name} field can be one of the following:
#'
#' \itemize{
#' \item \code{label}: label Xgboost learn from ;
#' \item \code{weight}: to do a weight rescale ;
#' \item \code{base_margin}: base margin is the base prediction Xgboost will boost from ;
#' \item \code{group}.
#' }
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#'
#' labels <- getinfo(dtrain, 'label')
#' setinfo(dtrain, 'label', 1-labels)
#' labels2 <- getinfo(dtrain, 'label')
#' stopifnot(all.equal(labels2, 1-labels))
#' @rdname setinfo
#' @export
setinfo <- function(object, ...) UseMethod("setinfo")
#' @rdname setinfo
#' @export
setinfo.xgb.DMatrix <- function(object, name, info, ...) {
if (name == "label") {
if (length(info) != nrow(object))
stop("The length of labels must equal to the number of rows in the input data")
.Call("XGDMatrixSetInfo_R", object, name, as.numeric(info),
PACKAGE = "xgboost")
return(TRUE)
}
if (name == "weight") {
if (length(info) != nrow(object))
stop("The length of weights must equal to the number of rows in the input data")
.Call("XGDMatrixSetInfo_R", object, name, as.numeric(info),
PACKAGE = "xgboost")
return(TRUE)
}
if (name == "base_margin") {
# if (length(info)!=nrow(object))
# stop("The length of base margin must equal to the number of rows in the input data")
.Call("XGDMatrixSetInfo_R", object, name, as.numeric(info),
PACKAGE = "xgboost")
return(TRUE)
}
if (name == "group") {
if (sum(info) != nrow(object))
stop("The sum of groups must equal to the number of rows in the input data")
.Call("XGDMatrixSetInfo_R", object, name, as.integer(info),
PACKAGE = "xgboost")
return(TRUE)
}
stop(paste("setinfo: unknown info name", name))
return(FALSE)
}
#' Get a new DMatrix containing the specified rows of
#' orginal xgb.DMatrix object
#'
#' Get a new DMatrix containing the specified rows of
#' orginal xgb.DMatrix object
#'
#' @param object Object of class "xgb.DMatrix"
#' @param idxset a integer vector of indices of rows needed
#' @param colset currently not used (columns subsetting is not available)
#' @param ... other parameters (currently not used)
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#'
#' dsub <- slice(dtrain, 1:42)
#' labels1 <- getinfo(dsub, 'label')
#' dsub <- dtrain[1:42, ]
#' labels2 <- getinfo(dsub, 'label')
#' all.equal(labels1, labels2)
#'
#' @rdname slice.xgb.DMatrix
#' @export
slice <- function(object, ...) UseMethod("slice")
#' @rdname slice.xgb.DMatrix
#' @export
slice.xgb.DMatrix <- function(object, idxset, ...) {
if (class(object) != "xgb.DMatrix") {
stop("slice: first argument dtrain must be xgb.DMatrix")
}
ret <- .Call("XGDMatrixSliceDMatrix_R", object, idxset, PACKAGE = "xgboost")
attr_list <- attributes(object)
nr <- nrow(object)
len <- sapply(attr_list, length)
ind <- which(len == nr)
if (length(ind) > 0) {
nms <- names(attr_list)[ind]
for (i in 1:length(ind)) {
attr(ret, nms[i]) <- attr(object, nms[i])[idxset]
}
}
return(structure(ret, class = "xgb.DMatrix"))
}
#' @rdname slice.xgb.DMatrix
#' @export
`[.xgb.DMatrix` <- function(object, idxset, colset=NULL) {
slice(object, idxset)
}
#' Print xgb.DMatrix
#'
#' Print information about xgb.DMatrix.
#' Currently it displays dimensions and presence of info-fields and colnames.
#'
#' @param x an xgb.DMatrix object
#' @param verbose whether to print colnames (when present)
#' @param ... not currently used
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
#'
#' dtrain
#' print(dtrain, verbose=TRUE)
#'
#' @method print xgb.DMatrix
#' @export
print.xgb.DMatrix <- function(x, verbose=FALSE, ...) {
cat('xgb.DMatrix dim:', nrow(x), 'x', ncol(x), ' info: ')
infos <- c()
if(length(getinfo(x, 'label')) > 0) infos <- 'label'
if(length(getinfo(x, 'weight')) > 0) infos <- c(infos, 'weight')
if(length(getinfo(x, 'base_margin')) > 0) infos <- c(infos, 'base_margin')
if (length(infos) == 0) infos <- 'NA'
cat(infos)
cnames <- colnames(x)
cat(' colnames:')
if (verbose & !is.null(cnames)) {
cat("\n'")
cat(cnames, sep="','")
cat("'")
} else {
if (is.null(cnames)) cat(' no')
else cat(' yes')
}
cat("\n")
invisible(x)
}

View File

@@ -2,8 +2,8 @@
#'
#' Save xgb.DMatrix object to binary file
#'
#' @param DMatrix the DMatrix object
#' @param fname the name of the binary file.
#' @param dmatrix the \code{xgb.DMatrix} object
#' @param fname the name of the file to write.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
@@ -12,16 +12,12 @@
#' xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
#' dtrain <- xgb.DMatrix('xgb.DMatrix.data')
#' @export
#'
xgb.DMatrix.save <- function(DMatrix, fname) {
if (typeof(fname) != "character") {
stop("xgb.save: fname must be character")
}
if (class(DMatrix) == "xgb.DMatrix") {
.Call("XGDMatrixSaveBinary_R", DMatrix, fname, as.integer(FALSE),
PACKAGE = "xgboost")
return(TRUE)
}
stop("xgb.DMatrix.save: the input must be xgb.DMatrix")
return(FALSE)
}
xgb.DMatrix.save <- function(dmatrix, fname) {
if (typeof(fname) != "character")
stop("fname must be character")
if (class(dmatrix) != "xgb.DMatrix")
stop("the input data must be xgb.DMatrix")
.Call("XGDMatrixSaveBinary_R", dmatrix, fname, 0L, PACKAGE = "xgboost")
return(TRUE)
}

View File

@@ -0,0 +1,84 @@
#' Create new features from a previously learned model
#'
#' May improve the learning by adding new features to the training data based on the decision trees from a previously learned model.
#'
#' @param model decision tree boosting model learned on the original data
#' @param data original data (usually provided as a \code{dgCMatrix} matrix)
#' @param ... currently not used
#'
#' @return \code{dgCMatrix} matrix including both the original data and the new features.
#'
#' @details
#' This is the function inspired from the paragraph 3.1 of the paper:
#'
#' \strong{Practical Lessons from Predicting Clicks on Ads at Facebook}
#'
#' \emph{(Xinran He, Junfeng Pan, Ou Jin, Tianbing Xu, Bo Liu, Tao Xu, Yan, xin Shi, Antoine Atallah, Ralf Herbrich, Stuart Bowers,
#' Joaquin Quinonero Candela)}
#'
#' International Workshop on Data Mining for Online Advertising (ADKDD) - August 24, 2014
#'
#' \url{https://research.facebook.com/publications/758569837499391/practical-lessons-from-predicting-clicks-on-ads-at-facebook/}.
#'
#' Extract explaining the method:
#'
#' "We found that boosted decision trees are a powerful and very
#' convenient way to implement non-linear and tuple transformations
#' of the kind we just described. We treat each individual
#' tree as a categorical feature that takes as value the
#' index of the leaf an instance ends up falling in. We use
#' 1-of-K coding of this type of features.
#'
#' For example, consider the boosted tree model in Figure 1 with 2 subtrees,
#' where the first subtree has 3 leafs and the second 2 leafs. If an
#' instance ends up in leaf 2 in the first subtree and leaf 1 in
#' second subtree, the overall input to the linear classifier will
#' be the binary vector \code{[0, 1, 0, 1, 0]}, where the first 3 entries
#' correspond to the leaves of the first subtree and last 2 to
#' those of the second subtree.
#'
#' [...]
#'
#' We can understand boosted decision tree
#' based transformation as a supervised feature encoding that
#' converts a real-valued vector into a compact binary-valued
#' vector. A traversal from root node to a leaf node represents
#' a rule on certain features."
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' data(agaricus.test, package='xgboost')
#' dtrain <- xgb.DMatrix(data = agaricus.train$data, label = agaricus.train$label)
#' dtest <- xgb.DMatrix(data = agaricus.test$data, label = agaricus.test$label)
#'
#' param <- list(max_depth=2, eta=1, silent=1, objective='binary:logistic')
#' nround = 4
#'
#' bst = xgb.train(params = param, data = dtrain, nrounds = nround, nthread = 2)
#'
#' # Model accuracy without new features
#' accuracy.before <- sum((predict(bst, agaricus.test$data) >= 0.5) == agaricus.test$label) / length(agaricus.test$label)
#'
#' # Convert previous features to one hot encoding
#' new.features.train <- xgb.create.features(model = bst, agaricus.train$data)
#' new.features.test <- xgb.create.features(model = bst, agaricus.test$data)
#'
#' # learning with new features
#' new.dtrain <- xgb.DMatrix(data = new.features.train, label = agaricus.train$label)
#' new.dtest <- xgb.DMatrix(data = new.features.test, label = agaricus.test$label)
#' watchlist <- list(train = new.dtrain)
#' bst <- xgb.train(params = param, data = new.dtrain, nrounds = nround, nthread = 2)
#'
#' # Model accuracy with new features
#' accuracy.after <- sum((predict(bst, new.dtest) >= 0.5) == agaricus.test$label) / length(agaricus.test$label)
#'
#' # Here the accuracy was already good and is now perfect.
#' cat(paste("The accuracy was", accuracy.before, "before adding leaf features and it is now", accuracy.after, "!\n"))
#'
#' @export
xgb.create.features <- function(model, data, ...){
check.deprecation(...)
pred_with_leaf <- predict(model, data, predleaf = TRUE)
cols <- lapply(as.data.frame(pred_with_leaf), factor)
cBind(data, sparse.model.matrix( ~ . -1, cols))
}

View File

@@ -1,7 +1,7 @@
#' Cross Validation
#'
#' The cross valudation function of xgboost
#'
#'
#' @param params the list of parameters. Commonly used ones are:
#' \itemize{
#' \item \code{objective} objective function, common ones are
@@ -10,18 +10,23 @@
#' \item \code{binary:logistic} logistic regression for classification
#' }
#' \item \code{eta} step size of each boosting step
#' \item \code{max.depth} maximum depth of the tree
#' \item \code{max_depth} maximum depth of the tree
#' \item \code{nthread} number of thread used in training, if not set, all threads are used
#' }
#'
#' See \url{https://github.com/tqchen/xgboost/wiki/Parameters} for
#' further details. See also demo/ for walkthrough example in R.
#' @param data takes an \code{xgb.DMatrix} as the input.
#' See \code{\link{xgb.train}} for further details.
#' See also demo/ for walkthrough example in R.
#' @param data takes an \code{xgb.DMatrix} or \code{Matrix} as the input.
#' @param nrounds the max number of iterations
#' @param nfold number of folds used
#' @param label option field, when data is Matrix
#' @param showsd boolean, whether show standard deviation of cross validation
#' @param metrics, list of evaluation metrics to be used in corss validation,
#' @param nfold the original dataset is randomly partitioned into \code{nfold} equal size subsamples.
#' @param label vector of response values. Should be provided only when data is \code{DMatrix}.
#' @param missing is only used when input is a dense matrix. By default is set to NA, which means
#' that NA values should be considered as 'missing' by the algorithm.
#' Sometimes, 0 or other extreme value might be used to represent missing values.
#' @param prediction A logical value indicating whether to return the test fold predictions
#' from each CV model. This parameter engages the \code{\link{cb.cv.predict}} callback.
#' @param showsd \code{boolean}, whether to show standard deviation of cross validation
#' @param metrics, list of evaluation metrics to be used in cross validation,
#' when it is not specified, the evaluation metric is chosen according to objective function.
#' Possible options are:
#' \itemize{
@@ -32,55 +37,266 @@
#' \item \code{merror} Exact matching error, used to evaluate multi-class classification
#' }
#' @param obj customized objective function. Returns gradient and second order
#' gradient with given prediction and dtrain,
#' gradient with given prediction and dtrain.
#' @param feval custimized evaluation function. Returns
#' \code{list(metric='metric-name', value='metric-value')} with given
#' prediction and dtrain,
#' \code{list(metric='metric-name', value='metric-value')} with given
#' prediction and dtrain.
#' @param stratified a \code{boolean} indicating whether sampling of folds should be stratified
#' by the values of outcome labels.
#' @param folds \code{list} provides a possibility to use a list of pre-defined CV folds
#' (each element must be a vector of test fold's indices). When folds are supplied,
#' the \code{nfold} and \code{stratified} parameters are ignored.
#' @param verbose \code{boolean}, print the statistics during the process
#' @param print_every_n Print each n-th iteration evaluation messages when \code{verbose>0}.
#' Default is 1 which means all messages are printed. This parameter is passed to the
#' \code{\link{cb.print.evaluation}} callback.
#' @param early_stopping_rounds If \code{NULL}, the early stopping function is not triggered.
#' If set to an integer \code{k}, training with a validation set will stop if the performance
#' doesn't improve for \code{k} rounds.
#' Setting this parameter engages the \code{\link{cb.early.stop}} callback.
#' @param maximize If \code{feval} and \code{early_stopping_rounds} are set,
#' then this parameter must be set as well.
#' When it is \code{TRUE}, it means the larger the evaluation score the better.
#' This parameter is passed to the \code{\link{cb.early.stop}} callback.
#' @param callbacks a list of callback functions to perform various task during boosting.
#' See \code{\link{callbacks}}. Some of the callbacks are automatically created depending on the
#' parameters' values. User can provide either existing or their own callback methods in order
#' to customize the training process.
#' @param ... other parameters to pass to \code{params}.
#'
#' @details
#' This is the cross validation function for xgboost
#'
#' Parallelization is automatically enabled if OpenMP is present.
#' Number of threads can also be manually specified via "nthread" parameter.
#' The original sample is randomly partitioned into \code{nfold} equal size subsamples.
#'
#' This function only accepts an \code{xgb.DMatrix} object as the input.
#' Of the \code{nfold} subsamples, a single subsample is retained as the validation data for testing the model, and the remaining \code{nfold - 1} subsamples are used as training data.
#'
#' The cross-validation process is then repeated \code{nrounds} times, with each of the \code{nfold} subsamples used exactly once as the validation data.
#'
#' All observations are used for both training and validation.
#'
#' Adapted from \url{http://en.wikipedia.org/wiki/Cross-validation_\%28statistics\%29#k-fold_cross-validation}
#'
#' @return
#' An object of class \code{xgb.cv.synchronous} with the following elements:
#' \itemize{
#' \item \code{call} a function call.
#' \item \code{params} parameters that were passed to the xgboost library. Note that it does not
#' capture parameters changed by the \code{\link{cb.reset.parameters}} callback.
#' \item \code{callbacks} callback functions that were either automatically assigned or
#' explicitely passed.
#' \item \code{evaluation_log} evaluation history storead as a \code{data.table} with the
#' first column corresponding to iteration number and the rest corresponding to the
#' CV-based evaluation means and standard deviations for the training and test CV-sets.
#' It is created by the \code{\link{cb.evaluation.log}} callback.
#' \item \code{niter} number of boosting iterations.
#' \item \code{folds} the list of CV folds' indices - either those passed through the \code{folds}
#' parameter or randomly generated.
#' \item \code{best_iteration} iteration number with the best evaluation metric value
#' (only available with early stopping).
#' \item \code{best_ntreelimit} the \code{ntreelimit} value corresponding to the best iteration,
#' which could further be used in \code{predict} method
#' (only available with early stopping).
#' \item \code{pred} CV prediction values available when \code{prediction} is set.
#' It is either vector or matrix (see \code{\link{cb.cv.predict}}).
#' \item \code{models} a liost of the CV folds' models. It is only available with the explicit
#' setting of the \code{cb.cv.predict(save_models = TRUE)} callback.
#' }
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)
#' history <- xgb.cv(data = dtrain, nround=3, nfold = 5, metrics=list("rmse","auc"),
#' "max.depth"=3, "eta"=1, "objective"="binary:logistic")
#' cv <- xgb.cv(data = dtrain, nrounds = 3, nthread = 2, nfold = 5, metrics = list("rmse","auc"),
#' max_depth = 3, eta = 1, objective = "binary:logistic")
#' print(cv)
#' print(cv, verbose=TRUE)
#'
#' @export
#'
xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL,
showsd = TRUE, metrics=list(), obj = NULL, feval = NULL, ...) {
if (typeof(params) != "list") {
stop("xgb.cv: first argument params must be list")
xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL, missing = NA,
prediction = FALSE, showsd = TRUE, metrics=list(),
obj = NULL, feval = NULL, stratified = TRUE, folds = NULL,
verbose = TRUE, print_every_n=1L,
early_stopping_rounds = NULL, maximize = NULL, callbacks = list(), ...) {
check.deprecation(...)
params <- check.booster.params(params, ...)
# TODO: should we deprecate the redundant 'metrics' parameter?
for (m in metrics)
params <- c(params, list("eval_metric" = m))
check.custom.obj()
check.custom.eval()
#if (is.null(params[['eval_metric']]) && is.null(feval))
# stop("Either 'eval_metric' or 'feval' must be provided for CV")
# Labels
if (class(data) == 'xgb.DMatrix')
labels <- getinfo(data, 'label')
if (is.null(labels))
stop("Labels must be provided for CV either through xgb.DMatrix, or through 'label=' when 'data' is matrix")
# CV folds
if(!is.null(folds)) {
if(class(folds) != "list" || length(folds) < 2)
stop("'folds' must be a list with 2 or more elements that are vectors of indices for each CV-fold")
nfold <- length(folds)
} else {
if (nfold <= 1)
stop("'nfold' must be > 1")
folds <- generate.cv.folds(nfold, nrow(data), stratified, label, params)
}
if (nfold <= 1) {
stop("nfold must be bigger than 1")
# Potential TODO: sequential CV
#if (strategy == 'sequential')
# stop('Sequential CV strategy is not yet implemented')
# verbosity & evaluation printing callback:
params <- c(params, list(silent = 1))
print_every_n <- max( as.integer(print_every_n), 1L)
if (!has.callbacks(callbacks, 'cb.print.evaluation') && verbose) {
callbacks <- add.cb(callbacks, cb.print.evaluation(print_every_n))
}
dtrain <- xgb.get.DMatrix(data, label)
params <- append(params, list(...))
params <- append(params, list(silent=1))
for (mc in metrics) {
params <- append(params, list("eval_metric"=mc))
# evaluation log callback: always is on in CV
evaluation_log <- list()
if (!has.callbacks(callbacks, 'cb.evaluation.log')) {
callbacks <- add.cb(callbacks, cb.evaluation.log())
}
# Early stopping callback
stop_condition <- FALSE
if (!is.null(early_stopping_rounds) &&
!has.callbacks(callbacks, 'cb.early.stop')) {
callbacks <- add.cb(callbacks, cb.early.stop(early_stopping_rounds,
maximize=maximize, verbose=verbose))
}
# CV-predictions callback
if (prediction &&
!has.callbacks(callbacks, 'cb.cv.predict')) {
callbacks <- add.cb(callbacks, cb.cv.predict(save_models=FALSE))
}
# Sort the callbacks into categories
cb <- categorize.callbacks(callbacks)
# create the booster-folds
dall <- xgb.get.DMatrix(data, label, missing)
bst_folds <- lapply(1:length(folds), function(k) {
dtest <- slice(dall, folds[[k]])
dtrain <- slice(dall, unlist(folds[-k]))
bst <- xgb.Booster(params, list(dtrain, dtest))
list(dtrain=dtrain, bst=bst, watchlist=list(train=dtrain, test=dtest), index=folds[[k]])
})
# a "basket" to collect some results from callbacks
basket <- list()
# extract parameters that can affect the relationship b/w #trees and #iterations
num_class <- max(as.numeric(NVL(params[['num_class']], 1)), 1)
num_parallel_tree <- max(as.numeric(NVL(params[['num_parallel_tree']], 1)), 1)
# those are fixed for CV (no training continuation)
begin_iteration <- 1
end_iteration <- nrounds
# synchronous CV boosting: run CV folds' models within each iteration
for (iteration in begin_iteration:end_iteration) {
for (f in cb$pre_iter) f()
msg <- lapply(bst_folds, function(fd) {
xgb.iter.update(fd$bst, fd$dtrain, iteration - 1, obj)
xgb.iter.eval(fd$bst, fd$watchlist, iteration - 1, feval)
})
msg <- simplify2array(msg)
bst_evaluation <- rowMeans(msg)
bst_evaluation_err <- sqrt(rowMeans(msg^2) - bst_evaluation^2)
for (f in cb$post_iter) f()
if (stop_condition) break
}
for (f in cb$finalize) f(finalize=TRUE)
# the CV result
ret <- list(
call = match.call(),
params = params,
callbacks = callbacks,
evaluation_log = evaluation_log,
niter = end_iteration,
folds = folds
)
ret <- c(ret, basket)
class(ret) <- 'xgb.cv.synchronous'
invisible(ret)
}
#' Print xgb.cv result
#'
#' Prints formatted results of \code{xgb.cv}.
#'
#' @param x an \code{xgb.cv.synchronous} object
#' @param verbose whether to print detailed data
#' @param ... passed to \code{data.table.print}
#'
#' @details
#' When not verbose, it would only print the evaluation results,
#' including the best iteration (when available).
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' train <- agaricus.train
#' cv <- xgb.cv(data = train$data, label = train$label, nfold = 5, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
#' print(cv)
#' print(cv, verbose=TRUE)
#'
#' @rdname print.xgb.cv
#' @method print xgb.cv.synchronous
#' @export
print.xgb.cv.synchronous <- function(x, verbose=FALSE, ...) {
cat('##### xgb.cv ', length(x$folds), '-folds\n', sep='')
if (verbose) {
if (!is.null(x$call)) {
cat('call:\n ')
print(x$call)
}
if (!is.null(x$params)) {
cat('params (as set within xgb.cv):\n')
cat( ' ',
paste(names(x$params),
paste0('"', unlist(x$params), '"'),
sep=' = ', collapse=', '), '\n', sep='')
}
if (!is.null(x$callbacks) && length(x$callbacks) > 0) {
cat('callbacks:\n')
lapply(callback.calls(x$callbacks), function(x) {
cat(' ')
print(x)
})
}
for (n in c('niter', 'best_iteration', 'best_ntreelimit')) {
if (is.null(x[[n]]))
next
cat(n, ': ', x[[n]], '\n', sep='')
}
if (!is.null(x$pred)) {
cat('pred:\n')
str(x$pred)
}
}
folds <- xgb.cv.mknfold(dtrain, nfold, params)
history <- list()
for (i in 1:nrounds) {
msg <- list()
for (k in 1:nfold) {
fd <- folds[[k]]
succ <- xgb.iter.update(fd$booster, fd$dtrain, i - 1, obj)
msg[[k]] <- strsplit(xgb.iter.eval(fd$booster, fd$watchlist, i - 1, feval),
"\t")[[1]]
}
ret <- xgb.cv.aggcv(msg, showsd)
history <- append(history, ret)
cat(paste(ret, "\n", sep=""))
if (verbose)
cat('evaluation_log:\n')
print(x$evaluation_log, row.names = FALSE, ...)
if (!is.null(x$best_iteration)) {
cat('Best iteration:\n')
print(x$evaluation_log[x$best_iteration], row.names = FALSE, ...)
}
return (TRUE)
invisible(x)
}

View File

@@ -3,31 +3,57 @@
#' Save a xgboost model to text file. Could be parsed later.
#'
#' @param model the model object.
#' @param fname the name of the binary file.
#' @param fname the name of the text file where to save the model text dump. If not provided or set to \code{NULL} the function will return the model as a \code{character} vector.
#' @param fmap feature map file representing the type of feature.
#' Detailed description could be found at
#' \url{https://github.com/tqchen/xgboost/wiki/Binary-Classification#dump-model}.
#' \url{https://github.com/dmlc/xgboost/wiki/Binary-Classification#dump-model}.
#' See demo/ for walkthrough example in R, and
#' \url{https://github.com/tqchen/xgboost/blob/master/demo/data/featmap.txt}
#' \url{https://github.com/dmlc/xgboost/blob/master/demo/data/featmap.txt}
#' for example Format.
#' @param with_stats whether dump statistics of splits
#' When this option is on, the model dump comes with two additional statistics:
#' gain is the approximate loss function gain we get in each split;
#' cover is the sum of second order gradient in each node.
#' @param ... currently not used
#'
#' @return
#' if fname is not provided or set to \code{NULL} the function will return the model as a \code{character} vector. Otherwise it will return \code{TRUE}.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' data(agaricus.test, package='xgboost')
#' train <- agaricus.train
#' test <- agaricus.test
#' bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
#' eta = 1, nround = 2,objective = "binary:logistic")
#' xgb.dump(bst, 'xgb.model.dump')
#' @export
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
#' # save the model in file 'xgb.model.dump'
#' xgb.dump(bst, 'xgb.model.dump', with_stats = TRUE)
#'
xgb.dump <- function(model, fname, fmap = "") {
if (class(model) != "xgb.Booster") {
stop("xgb.dump: first argument must be type xgb.Booster")
#' # print the model without saving it to a file
#' print(xgb.dump(bst))
#' @export
xgb.dump <- function(model = NULL, fname = NULL, fmap = "", with_stats=FALSE, ...) {
check.deprecation(...)
if (class(model) != "xgb.Booster")
stop("model: argument must be of type xgb.Booster")
if (!(class(fname) %in% c("character", "NULL") && length(fname) <= 1))
stop("fname: argument must be of type character (when provided)")
if (!(class(fmap) %in% c("character", "NULL") && length(fmap) <= 1))
stop("fmap: argument must be of type character (when provided)")
model <- xgb.Booster.check(model)
model_dump <- .Call("XGBoosterDumpModel_R", model$handle, fmap, as.integer(with_stats), PACKAGE = "xgboost")
if (is.null(fname))
model_dump <- stri_replace_all_regex(model_dump, '\t', '')
model_dump <- unlist(stri_split_regex(model_dump, '\n'))
model_dump <- grep('^\\s*$', model_dump, invert = TRUE, value = TRUE)
if (is.null(fname)) {
return(model_dump)
} else {
writeLines(model_dump, fname)
return(TRUE)
}
if (typeof(fname) != "character") {
stop("xgb.dump: second argument must be type character")
}
.Call("XGBoosterDumpModel_R", model, fname, fmap, PACKAGE = "xgboost")
return(TRUE)
}
}

135
R-package/R/xgb.ggplot.R Normal file
View File

@@ -0,0 +1,135 @@
# ggplot backend for the xgboost plotting facilities
#' @rdname xgb.plot.importance
#' @export
xgb.ggplot.importance <- function(importance_matrix = NULL, top_n = NULL, measure = NULL,
rel_to_first = FALSE, n_clusters = c(1:10), ...) {
importance_matrix <- xgb.plot.importance(importance_matrix, top_n = top_n, measure = measure,
rel_to_first = rel_to_first, plot = FALSE, ...)
if (!requireNamespace("ggplot2", quietly = TRUE)) {
stop("ggplot2 package is required", call. = FALSE)
}
if (!requireNamespace("Ckmeans.1d.dp", quietly = TRUE)) {
stop("Ckmeans.1d.dp package is required", call. = FALSE)
}
clusters <- suppressWarnings(
Ckmeans.1d.dp::Ckmeans.1d.dp(importance_matrix$Importance, n_clusters)
)
importance_matrix[, Cluster := as.character(clusters$cluster)]
plot <-
ggplot2::ggplot(importance_matrix,
ggplot2::aes(x = factor(Feature, levels = rev(Feature)), y = Importance, width = 0.05),
environment = environment()) +
ggplot2::geom_bar(ggplot2::aes(fill = Cluster), stat = "identity", position = "identity") +
ggplot2::coord_flip() +
ggplot2::xlab("Features") +
ggplot2::ggtitle("Feature importance") +
ggplot2::theme(plot.title = ggplot2::element_text(lineheight = .9, face = "bold"),
panel.grid.major.y = ggplot2::element_blank())
return(plot)
}
#' @rdname xgb.plot.deepness
#' @export
xgb.ggplot.deepness <- function(model = NULL, which = c("2x1", "max.depth", "med.depth", "med.weight")) {
if (!requireNamespace("ggplot2", quietly = TRUE))
stop("ggplot2 package is required for plotting the graph deepness.", call. = FALSE)
which <- match.arg(which)
dt_depths <- xgb.plot.deepness(model = model, plot = FALSE)
dt_summaries <- dt_depths[, .(.N, Cover = mean(Cover)), Depth]
setkey(dt_summaries, 'Depth')
if (which == "2x1") {
p1 <-
ggplot2::ggplot(dt_summaries) +
ggplot2::geom_bar(ggplot2::aes(x = Depth, y = N), stat = "Identity") +
ggplot2::xlab("") +
ggplot2::ylab("Number of leafs") +
ggplot2::ggtitle("Model complexity") +
ggplot2::theme(
plot.title = ggplot2::element_text(lineheight = 0.9, face = "bold"),
panel.grid.major.y = ggplot2::element_blank(),
axis.ticks = ggplot2::element_blank(),
axis.text.x = ggplot2::element_blank()
)
p2 <-
ggplot2::ggplot(dt_summaries) +
ggplot2::geom_bar(ggplot2::aes(x = Depth, y = Cover), stat = "Identity") +
ggplot2::xlab("Leaf depth") +
ggplot2::ylab("Weighted cover")
multiplot(p1, p2, cols = 1)
return(invisible(list(p1, p2)))
} else if (which == "max.depth") {
p <-
ggplot2::ggplot(dt_depths[, max(Depth), Tree]) +
ggplot2::geom_jitter(ggplot2::aes(x = Tree, y = V1),
height = 0.15, alpha=0.4, size=3, stroke=0) +
ggplot2::xlab("tree #") +
ggplot2::ylab("Max tree leaf depth")
return(p)
} else if (which == "med.depth") {
p <-
ggplot2::ggplot(dt_depths[, median(as.numeric(Depth)), Tree]) +
ggplot2::geom_jitter(ggplot2::aes(x = Tree, y = V1),
height = 0.15, alpha=0.4, size=3, stroke=0) +
ggplot2::xlab("tree #") +
ggplot2::ylab("Median tree leaf depth")
return(p)
} else if (which == "med.weight") {
p <-
ggplot2::ggplot(dt_depths[, median(abs(Weight)), Tree]) +
ggplot2::geom_point(ggplot2::aes(x = Tree, y = V1),
alpha=0.4, size=3, stroke=0) +
ggplot2::xlab("tree #") +
ggplot2::ylab("Median absolute leaf weight")
return(p)
}
}
# Plot multiple ggplot graph aligned by rows and columns.
# ... the plots
# cols number of columns
# internal utility function
multiplot <- function(..., cols = 1) {
plots <- list(...)
num_plots = length(plots)
layout <- matrix(seq(1, cols * ceiling(num_plots / cols)),
ncol = cols, nrow = ceiling(num_plots / cols))
if (num_plots == 1) {
print(plots[[1]])
} else {
grid::grid.newpage()
grid::pushViewport(grid::viewport(layout = grid::grid.layout(nrow(layout), ncol(layout))))
for (i in 1:num_plots) {
# Get the i,j matrix positions of the regions that contain this subplot
matchidx <- as.data.table(which(layout == i, arr.ind = TRUE))
print(
plots[[i]], vp = grid::viewport(
layout.pos.row = matchidx$row,
layout.pos.col = matchidx$col
)
)
}
}
}
globalVariables(c(
"Cluster", "ggplot", "aes", "geom_bar", "coord_flip", "xlab", "ylab", "ggtitle", "theme",
"element_blank", "element_text"
))

View File

@@ -0,0 +1,106 @@
#' Show importance of features in a model
#'
#' Create a \code{data.table} of the most important features of a model.
#'
#' @param feature_names names of each feature as a \code{character} vector. Can be extracted from a sparse matrix (see example). If model dump already contains feature names, this argument should be \code{NULL}.
#' @param model generated by the \code{xgb.train} function.
#' @param data the dataset used for the training step. Will be used with \code{label} parameter for co-occurence computation. More information in \code{Detail} part. This parameter is optional.
#' @param label the label vetor used for the training step. Will be used with \code{data} parameter for co-occurence computation. More information in \code{Detail} part. This parameter is optional.
#' @param target a function which returns \code{TRUE} or \code{1} when an observation should be count as a co-occurence and \code{FALSE} or \code{0} otherwise. Default function is provided for computing co-occurences in a binary classification. The \code{target} function should have only one parameter. This parameter will be used to provide each important feature vector after having applied the split condition, therefore these vector will be only made of 0 and 1 only, whatever was the information before. More information in \code{Detail} part. This parameter is optional.
#'
#' @return A \code{data.table} of the features used in the model with their average gain (and their weight for boosted tree model) in the model.
#'
#' @details
#' This function is for both linear and tree models.
#'
#' \code{data.table} is returned by the function.
#' The columns are :
#' \itemize{
#' \item \code{Features} name of the features as provided in \code{feature_names} or already present in the model dump;
#' \item \code{Gain} contribution of each feature to the model. For boosted tree model, each gain of each feature of each tree is taken into account, then average per feature to give a vision of the entire model. Highest percentage means important feature to predict the \code{label} used for the training (only available for tree models);
#' \item \code{Cover} metric of the number of observation related to this feature (only available for tree models);
#' \item \code{Weight} percentage representing the relative number of times a feature have been taken into trees.
#' }
#'
#' If you don't provide \code{feature_names}, index of the features will be used instead.
#'
#' Because the index is extracted from the model dump (made on the C++ side), it starts at 0 (usual in C++) instead of 1 (usual in R).
#'
#' Co-occurence count
#' ------------------
#'
#' The gain gives you indication about the information of how a feature is important in making a branch of a decision tree more pure. However, with this information only, you can't know if this feature has to be present or not to get a specific classification. In the example code, you may wonder if odor=none should be \code{TRUE} to not eat a mushroom.
#'
#' Co-occurence computation is here to help in understanding this relation between a predictor and a specific class. It will count how many observations are returned as \code{TRUE} by the \code{target} function (see parameters). When you execute the example below, there are 92 times only over the 3140 observations of the train dataset where a mushroom have no odor and can be eaten safely.
#'
#' If you need to remember one thing only: until you want to leave us early, don't eat a mushroom which has no odor :-)
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#'
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
#'
#' xgb.importance(colnames(agaricus.train$data), model = bst)
#'
#' # Same thing with co-occurence computation this time
#' xgb.importance(colnames(agaricus.train$data), model = bst, data = agaricus.train$data, label = agaricus.train$label)
#'
#' @export
xgb.importance <- function(feature_names = NULL, model = NULL, data = NULL, label = NULL, target = function(x) ( (x + label) == 2)){
if (!class(feature_names) %in% c("character", "NULL")) {
stop("feature_names: Has to be a vector of character or NULL if the model already contains feature name. Look at this function documentation to see where to get feature names.")
}
if (class(model) != "xgb.Booster") {
stop("model: Has to be an object of class xgb.Booster model generaged by the xgb.train function.")
}
if((is.null(data) & !is.null(label)) | (!is.null(data) & is.null(label))) {
stop("data/label: Provide the two arguments if you want co-occurence computation or none of them if you are not interested but not one of them only.")
}
if(class(label) == "numeric"){
if(sum(label == 0) / length(label) > 0.5) label <- as(label, "sparseVector")
}
treeDump <- function(feature_names, text, keepDetail){
if(keepDetail) groupBy <- c("Feature", "Split", "MissingNo") else groupBy <- "Feature"
xgb.model.dt.tree(feature_names = feature_names, text = text)[,"MissingNo" := Missing == No ][Feature != "Leaf",.(Gain = sum(Quality), Cover = sum(Cover), Frequency = .N), by = groupBy, with = T][,`:=`(Gain = Gain / sum(Gain), Cover = Cover / sum(Cover), Frequency = Frequency / sum(Frequency))][order(Gain, decreasing = T)]
}
linearDump <- function(feature_names, text){
weights <- which(text == "weight:") %>% {a =. + 1; text[a:length(text)]} %>% as.numeric
if(is.null(feature_names)) feature_names <- seq(to = length(weights))
data.table(Feature = feature_names, Weight = weights)
}
model.text.dump <- xgb.dump(model = model, with_stats = T)
if(model.text.dump[2] == "bias:"){
result <- model.text.dump %>% linearDump(feature_names, .)
if(!is.null(data) | !is.null(label)) warning("data/label: these parameters should only be provided with decision tree based models.")
} else {
result <- treeDump(feature_names, text = model.text.dump, keepDetail = !is.null(data))
# Co-occurence computation
if(!is.null(data) & !is.null(label) & nrow(result) > 0) {
# Take care of missing column
a <- data[, result[MissingNo == T,Feature], drop=FALSE] != 0
# Bind the two Matrix and reorder columns
c <- data[, result[MissingNo == F,Feature], drop=FALSE] %>% cBind(a,.) %>% .[,result[,Feature]]
rm(a)
# Apply split
d <- data[, result[,Feature], drop=FALSE] < as.numeric(result[,Split])
apply(c & d, 2, . %>% target %>% sum) -> vec
result <- result[, "RealCover" := as.numeric(vec), with = F][, "RealCover %" := RealCover / sum(label)][,MissingNo := NULL]
}
}
result
}
# Avoid error messages during CRAN check.
# The reason is that these variables are never declared
# They are mainly column names inferred by Data.table...
globalVariables(c(".", ".N", "Gain", "Frequency", "Feature", "Split", "No", "Missing", "MissingNo", "RealCover"))

View File

@@ -9,15 +9,23 @@
#' data(agaricus.test, package='xgboost')
#' train <- agaricus.train
#' test <- agaricus.test
#' bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
#' eta = 1, nround = 2,objective = "binary:logistic")
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
#' xgb.save(bst, 'xgb.model')
#' bst <- xgb.load('xgb.model')
#' pred <- predict(bst, test$data)
#' @export
#'
xgb.load <- function(modelfile) {
if (is.null(modelfile))
if (is.null(modelfile))
stop("xgb.load: modelfile cannot be NULL")
xgb.Booster(modelfile = modelfile)
}
handle <- xgb.Booster(modelfile = modelfile)
# re-use modelfile if it is raw so we donot need to serialize
if (typeof(modelfile) == "raw") {
bst <- xgb.handleToBooster(handle, modelfile)
} else {
bst <- xgb.handleToBooster(handle, NULL)
}
bst <- xgb.Booster.check(bst, saveraw = TRUE)
return(bst)
}

View File

@@ -0,0 +1,122 @@
#' Parse a boosted tree model text dump
#'
#' Parse a boosted tree model text dump into a \code{data.table} structure.
#'
#' @param feature_names character vector of feature names. If the model already
#' contains feature names, this argument should be \code{NULL} (default value)
#' @param model object of class \code{xgb.Booster}
#' @param text \code{character} vector previously generated by the \code{xgb.dump}
#' function (where parameter \code{with_stats = TRUE} should have been set).
#' @param n_first_tree limit the parsing to the \code{n} first trees.
#' If set to \code{NULL}, all trees of the model are parsed.
#'
#' @return
#' A \code{data.table} with detailed information about model trees' nodes.
#'
#' The columns of the \code{data.table} are:
#'
#' \itemize{
#' \item \code{Tree}: ID of a tree in a model
#' \item \code{Node}: ID of a node in a tree
#' \item \code{ID}: unique identifier of a node in a model
#' \item \code{Feature}: for a branch node, it's a feature id or name (when available);
#' for a leaf note, it simply labels it as \code{'Leaf'}
#' \item \code{Split}: location of the split for a branch node (split condition is always "less than")
#' \item \code{Yes}: ID of the next node when the split condition is met
#' \item \code{No}: ID of the next node when the split condition is not met
#' \item \code{Missing}: ID of the next node when branch value is missing
#' \item \code{Quality}: either the split gain (change in loss) or the leaf value
#' \item \code{Cover}: metric related to the number of observation either seen by a split
#' or collected by a leaf during training.
#' }
#'
#' @examples
#' # Basic use:
#'
#' data(agaricus.train, package='xgboost')
#'
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
#'
#' (dt <- xgb.model.dt.tree(colnames(agaricus.train$data), bst))
#'
#'
#' # How to match feature names of splits that are following a current 'Yes' branch:
#'
#' merge(dt, dt[, .(ID, Y.Feature=Feature)], by.x='Yes', by.y='ID', all.x=TRUE)[order(Tree,Node)]
#'
#' @export
xgb.model.dt.tree <- function(feature_names = NULL, model = NULL, text = NULL,
n_first_tree = NULL){
if (!class(feature_names) %in% c("character", "NULL")) {
stop("feature_names: Has to be a vector of character\n",
" or NULL if the model dump already contains feature names.\n",
" Look at this function documentation to see where to get feature names.")
}
if (class(model) != "xgb.Booster" & class(text) != "character") {
stop("Either 'model' has to be an object of class xgb.Booster\n",
" or 'text' has to be a character vector with the result of xgb.dump\n",
" (or NULL if the model was provided).")
}
if (!class(n_first_tree) %in% c("numeric", "NULL") | length(n_first_tree) > 1) {
stop("n_first_tree: Has to be a numeric vector of size 1.")
}
if(is.null(text)){
text <- xgb.dump(model = model, with_stats = T)
}
position <- which(!is.na(stri_match_first_regex(text, "booster")))
add.tree.id <- function(x, i) paste(i, x, sep = "-")
anynumber_regex <- "[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"
td <- data.table(t=text)
td[position, Tree := 1L]
td[, Tree := cumsum(ifelse(is.na(Tree), 0L, Tree)) - 1L]
n_first_tree <- min(max(td$Tree), n_first_tree)
td <- td[Tree <= n_first_tree & !grepl('^booster', t)]
td[, Node := stri_match_first_regex(t, "(\\d+):")[,2] %>% as.numeric ]
td[, ID := add.tree.id(Node, Tree)]
td[, isLeaf := !is.na(stri_match_first_regex(t, "leaf"))]
# parse branch lines
td[isLeaf==FALSE, c("Feature", "Split", "Yes", "No", "Missing", "Quality", "Cover") := {
rx <- paste0("f(\\d+)<(", anynumber_regex, ")\\] yes=(\\d+),no=(\\d+),missing=(\\d+),",
"gain=(", anynumber_regex, "),cover=(", anynumber_regex, ")")
# skip some indices with spurious capture groups from anynumber_regex
xtr <- stri_match_first_regex(t, rx)[, c(2,3,5,6,7,8,10)]
xtr[, 3:5] <- add.tree.id(xtr[, 3:5], Tree)
lapply(1:ncol(xtr), function(i) xtr[,i])
}]
# assign feature_names when available
td[isLeaf==FALSE & !is.null(feature_names),
Feature := feature_names[as.numeric(Feature) + 1] ]
# parse leaf lines
td[isLeaf==TRUE, c("Feature", "Quality", "Cover") := {
rx <- paste0("leaf=(", anynumber_regex, "),cover=(", anynumber_regex, ")")
xtr <- stri_match_first_regex(t, rx)[, c(2,4)]
c("Leaf", lapply(1:ncol(xtr), function(i) xtr[,i]))
}]
# convert some columns to numeric
numeric_cols <- c("Quality", "Cover")
td[, (numeric_cols) := lapply(.SD, as.numeric), .SDcols=numeric_cols]
td[, t := NULL]
td[, isLeaf := NULL]
td[order(Tree, Node)]
}
# Avoid error messages during CRAN check.
# The reason is that these variables are never declared
# They are mainly column names inferred by Data.table...
globalVariables(c("Tree", "Node", "ID", "Feature", "t", "isLeaf",".SD", ".SDcols"))

View File

@@ -0,0 +1,149 @@
#' Plot model trees deepness
#'
#' Visualizes distributions related to depth of tree leafs.
#' \code{xgb.plot.deepness} uses base R graphics, while \code{xgb.ggplot.deepness} uses the ggplot backend.
#'
#' @param model either an \code{xgb.Booster} model generated by the \code{xgb.train} function
#' or a data.table result of the \code{xgb.model.dt.tree} function.
#' @param plot (base R barplot) whether a barplot should be produced.
#' If FALSE, only a data.table is returned.
#' @param which which distribution to plot (see details).
#' @param ... other parameters passed to \code{barplot} or \code{plot}.
#'
#' @details
#'
#' When \code{which="2x1"}, two distributions with respect to the leaf depth
#' are plotted on top of each other:
#' \itemize{
#' \item the distribution of the number of leafs in a tree model at a certain depth;
#' \item the distribution of average weighted number of observations ("cover")
#' ending up in leafs at certain depth.
#' }
#' Those could be helpful in determining sensible ranges of the \code{max_depth}
#' and \code{min_child_weight} parameters.
#'
#' When \code{which="max.depth"} or \code{which="med.depth"}, plots of either maximum or median depth
#' per tree with respect to tree number are created. And \code{which="med.weight"} allows to see how
#' a tree's median absolute leaf weight changes through the iterations.
#'
#' This function was inspired by the blog post
#' \url{http://aysent.github.io/2015/11/08/random-forest-leaf-visualization.html}.
#'
#' @return
#'
#' Other than producing plots (when \code{plot=TRUE}), the \code{xgb.plot.deepness} function
#' silently returns a processed data.table where each row corresponds to a terminal leaf in a tree model,
#' and contains information about leaf's depth, cover, and weight (which is used in calculating predictions).
#'
#' The \code{xgb.ggplot.deepness} silently returns either a list of two ggplot graphs when \code{which="2x1"}
#' or a single ggplot graph for the other \code{which} options.
#'
#' @seealso
#'
#' \code{\link{xgb.train}}, \code{\link{xgb.model.dt.tree}}.
#'
#' @examples
#'
#' data(agaricus.train, package='xgboost')
#'
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 15,
#' eta = 0.1, nthread = 2, nrounds = 50, objective = "binary:logistic",
#' subsample = 0.5, min_child_weight = 2)
#'
#' xgb.plot.deepness(bst)
#' xgb.ggplot.deepness(bst)
#'
#' xgb.plot.deepness(bst, which='max.depth', pch=16, col=rgb(0,0,1,0.3), cex=2)
#'
#' xgb.plot.deepness(bst, which='med.weight', pch=16, col=rgb(0,0,1,0.3), cex=2)
#'
#' @rdname xgb.plot.deepness
#' @export
xgb.plot.deepness <- function(model = NULL, which = c("2x1", "max.depth", "med.depth", "med.weight"),
plot = TRUE, ...) {
if (!(class(model) == "xgb.Booster" || is.data.table(model)))
stop("model: Has to be either an xgb.Booster model generaged by the xgb.train function\n",
"or a data.table result of the xgb.importance function")
if (!requireNamespace("igraph", quietly = TRUE))
stop("igraph package is required for plotting the graph deepness.", call. = FALSE)
which <- match.arg(which)
dt_tree <- model
if (class(model) == "xgb.Booster")
dt_tree <- xgb.model.dt.tree(model = model)
if (!all(c("Feature", "Tree", "ID", "Yes", "No", "Cover") %in% colnames(dt_tree)))
stop("Model tree columns are not as expected!\n",
" Note that this function works only for tree models.")
dt_depths <- merge(get.leaf.depth(dt_tree), dt_tree[, .(ID, Cover, Weight=Quality)], by = "ID")
setkeyv(dt_depths, c("Tree", "ID"))
# count by depth levels, and also calculate average cover at a depth
dt_summaries <- dt_depths[, .(.N, Cover = mean(Cover)), Depth]
setkey(dt_summaries, "Depth")
if (plot) {
if (which == "2x1") {
op <- par(no.readonly = TRUE)
par(mfrow=c(2,1),
oma = c(3,1,3,1) + 0.1,
mar = c(1,4,1,0) + 0.1)
dt_summaries[, barplot(N, border=NA, ylab = 'Number of leafs', ...)]
dt_summaries[, barplot(Cover, border=NA, ylab = "Weighted cover", names.arg=Depth, ...)]
title("Model complexity", xlab = "Leaf depth", outer = TRUE, line = 1)
par(op)
} else if (which == "max.depth") {
dt_depths[, max(Depth), Tree][
, plot(jitter(V1, amount = 0.1) ~ Tree, ylab = 'Max tree leaf depth', xlab = "tree #", ...)]
} else if (which == "med.depth") {
dt_depths[, median(as.numeric(Depth)), Tree][
, plot(jitter(V1, amount = 0.1) ~ Tree, ylab = 'Median tree leaf depth', xlab = "tree #", ...)]
} else if (which == "med.weight") {
dt_depths[, median(abs(Weight)), Tree][
, plot(V1 ~ Tree, ylab = 'Median absolute leaf weight', xlab = "tree #", ...)]
}
}
invisible(dt_depths)
}
# Extract path depths from root to leaf
# from data.table containing the nodes and edges of the trees.
# internal utility function
get.leaf.depth <- function(dt_tree) {
# extract tree graph's edges
dt_edges <- rbindlist(list(
dt_tree[Feature != "Leaf", .(ID, To=Yes, Tree)],
dt_tree[Feature != "Leaf", .(ID, To=No, Tree)]
))
# whether "To" is a leaf:
dt_edges <-
merge(dt_edges,
dt_tree[Feature == "Leaf", .(ID, Leaf = TRUE)],
all.x = TRUE, by.x = "To", by.y = "ID")
dt_edges[is.na(Leaf), Leaf := FALSE]
dt_edges[, {
graph <- igraph::graph_from_data_frame(.SD[,.(ID, To)])
# min(ID) in a tree is a root node
paths_tmp <- igraph::shortest_paths(graph, from = min(ID), to = To[Leaf == TRUE])
# list of paths to each leaf in a tree
paths <- lapply(paths_tmp$vpath, names)
# combine into a resulting path lengths table for a tree
data.table(Depth = sapply(paths, length), ID = To[Leaf == TRUE])
}, by = Tree]
}
# Avoid error messages during CRAN check.
# The reason is that these variables are never declared
# They are mainly column names inferred by Data.table...
globalVariables(
c(
".N", "N", "Depth", "Quality", "Cover", "Tree", "ID", "Yes", "No", "Feature"
)
)

View File

@@ -0,0 +1,125 @@
#' Plot feature importance as a bar graph
#'
#' Represents previously calculated feature importance as a bar graph.
#' \code{xgb.plot.importance} uses base R graphics, while \code{xgb.ggplot.importance} uses the ggplot backend.
#'
#' @param importance_matrix a \code{data.table} returned by \code{\link{xgb.importance}}.
#' @param top_n maximal number of top features to include into the plot.
#' @param measure the name of importance measure to plot.
#' When \code{NULL}, 'Gain' would be used for trees and 'Weight' would be used for gblinear.
#' @param rel_to_first whether importance values should be represented as relative to the highest ranked feature.
#' See Details.
#' @param left_margin (base R barplot) allows to adjust the left margin size to fit feature names.
#' When it is NULL, the existing \code{par('mar')} is used.
#' @param cex (base R barplot) passed as \code{cex.names} parameter to \code{barplot}.
#' @param plot (base R barplot) whether a barplot should be produced.
#' If FALSE, only a data.table is returned.
#' @param n_clusters (ggplot only) a \code{numeric} vector containing the min and the max range
#' of the possible number of clusters of bars.
#' @param ... other parameters passed to \code{barplot} (except horiz, border, cex.names, names.arg, and las).
#'
#' @details
#' The graph represents each feature as a horizontal bar of length proportional to the importance of a feature.
#' Features are shown ranked in a decreasing importance order.
#' It works for importances from both \code{gblinear} and \code{gbtree} models.
#'
#' When \code{rel_to_first = FALSE}, the values would be plotted as they were in \code{importance_matrix}.
#' For gbtree model, that would mean being normalized to the total of 1
#' ("what is feature's importance contribution relative to the whole model?").
#' For linear models, \code{rel_to_first = FALSE} would show actual values of the coefficients.
#' Setting \code{rel_to_first = TRUE} allows to see the picture from the perspective of
#' "what is feature's importance contribution relative to the most important feature?"
#'
#' The ggplot-backend method also performs 1-D custering of the importance values,
#' with bar colors coresponding to different clusters that have somewhat similar importance values.
#'
#' @return
#' The \code{xgb.plot.importance} function creates a \code{barplot} (when \code{plot=TRUE})
#' and silently returns a processed data.table with \code{n_top} features sorted by importance.
#'
#' The \code{xgb.ggplot.importance} function returns a ggplot graph which could be customized afterwards.
#' E.g., to change the title of the graph, add \code{+ ggtitle("A GRAPH NAME")} to the result.
#'
#' @seealso
#' \code{\link[graphics]{barplot}}.
#'
#' @examples
#' data(agaricus.train)
#'
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 3,
#' eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
#'
#' importance_matrix <- xgb.importance(colnames(agaricus.train$data), model = bst)
#'
#' xgb.plot.importance(importance_matrix, rel_to_first = TRUE, xlab = "Relative importance")
#'
#' (gg <- xgb.ggplot.importance(importance_matrix, measure = "Frequency", rel_to_first = TRUE))
#' gg + ggplot2::ylab("Frequency")
#'
#' @rdname xgb.plot.importance
#' @export
xgb.plot.importance <- function(importance_matrix = NULL, top_n = NULL, measure = NULL,
rel_to_first = FALSE, left_margin = 10, cex = NULL, plot = TRUE, ...) {
check.deprecation(...)
if (!"data.table" %in% class(importance_matrix)) {
stop("importance_matrix: Should be a data.table.")
}
imp_names <- colnames(importance_matrix)
if (is.null(measure)) {
if (all(c("Feature", "Gain") %in% imp_names)) {
measure <- "Gain"
} else if (all(c("Feature", "Weight") %in% imp_names)) {
measure <- "Weight"
} else {
stop("Importance matrix column names are not as expected!")
}
} else {
if (!measure %in% imp_names)
stop("Invalid `measure`")
if (!"Feature" %in% imp_names)
stop("Importance matrix column names are not as expected!")
}
# also aggregate, just in case when the values were not yet summed up by feature
importance_matrix <- importance_matrix[, Importance := sum(get(measure)), by = Feature]
# make sure it's ordered
importance_matrix <- importance_matrix[order(-abs(Importance))]
if (!is.null(top_n)) {
top_n <- min(top_n, nrow(importance_matrix))
importance_matrix <- head(importance_matrix, top_n)
}
if (rel_to_first) {
importance_matrix[, Importance := Importance/max(abs(Importance))]
}
if (is.null(cex)) {
cex <- 2.5/log2(1 + nrow(importance_matrix))
}
if (plot) {
op <- par(no.readonly = TRUE)
mar <- op$mar
if (!is.null(left_margin))
mar[2] <- left_margin
par(mar = mar)
# reverse the order of rows to have the highest ranked at the top
importance_matrix[nrow(importance_matrix):1,
barplot(Importance, horiz=TRUE, border=NA, cex.names=cex,
names.arg=Feature, las=1, ...)]
grid(NULL, NA)
# redraw over the grid
importance_matrix[nrow(importance_matrix):1,
barplot(Importance, horiz=TRUE, border=NA, add=TRUE)]
par(op)
}
invisible(importance_matrix)
}
# Avoid error messages during CRAN check.
# The reason is that these variables are never declared
# They are mainly column names inferred by Data.table...
globalVariables(c("Feature", "Importance"))

View File

@@ -0,0 +1,108 @@
#' Project all trees on one tree and plot it
#'
#' Visualization of the ensemble of trees as a single collective unit.
#'
#' @param model dump generated by the \code{xgb.train} function.
#' @param feature_names names of each feature as a \code{character} vector. Can be extracted from a sparse matrix (see example). If model dump already contains feature names, this argument should be \code{NULL}.
#' @param features_keep number of features to keep in each position of the multi trees.
#' @param plot_width width in pixels of the graph to produce
#' @param plot_height height in pixels of the graph to produce
#' @param ... currently not used
#'
#' @return Two graphs showing the distribution of the model deepness.
#'
#' @details
#'
#' This function tries to capture the complexity of gradient boosted tree ensemble
#' in a cohesive way.
#'
#' The goal is to improve the interpretability of the model generally seen as black box.
#' The function is dedicated to boosting applied to decision trees only.
#'
#' The purpose is to move from an ensemble of trees to a single tree only.
#'
#' It takes advantage of the fact that the shape of a binary tree is only defined by
#' its deepness (therefore in a boosting model, all trees have the same shape).
#'
#' Moreover, the trees tend to reuse the same features.
#'
#' The function will project each tree on one, and keep for each position the
#' \code{features_keep} first features (based on Gain per feature measure).
#'
#' This function is inspired by this blog post:
#' \url{https://wellecks.wordpress.com/2015/02/21/peering-into-the-black-box-visualizing-lambdamart/}
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#'
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 15,
#' eta = 1, nthread = 2, nrounds = 30, objective = "binary:logistic",
#' min_child_weight = 50)
#'
#' p <- xgb.plot.multi.trees(model = bst, feature_names = colnames(agaricus.train$data), features_keep = 3)
#' print(p)
#'
#' @export
xgb.plot.multi.trees <- function(model, feature_names = NULL, features_keep = 5, plot_width = NULL, plot_height = NULL, ...){
check.deprecation(...)
tree.matrix <- xgb.model.dt.tree(feature_names = feature_names, model = model)
# first number of the path represents the tree, then the following numbers are related to the path to follow
# root init
root.nodes <- tree.matrix[stri_detect_regex(ID, "\\d+-0"), ID]
tree.matrix[ID %in% root.nodes, abs.node.position:=root.nodes]
precedent.nodes <- root.nodes
while(tree.matrix[,sum(is.na(abs.node.position))] > 0) {
yes.row.nodes <- tree.matrix[abs.node.position %in% precedent.nodes & !is.na(Yes)]
no.row.nodes <- tree.matrix[abs.node.position %in% precedent.nodes & !is.na(No)]
yes.nodes.abs.pos <- yes.row.nodes[, abs.node.position] %>% paste0("_0")
no.nodes.abs.pos <- no.row.nodes[, abs.node.position] %>% paste0("_1")
tree.matrix[ID %in% yes.row.nodes[, Yes], abs.node.position := yes.nodes.abs.pos]
tree.matrix[ID %in% no.row.nodes[, No], abs.node.position := no.nodes.abs.pos]
precedent.nodes <- c(yes.nodes.abs.pos, no.nodes.abs.pos)
}
tree.matrix[!is.na(Yes),Yes:= paste0(abs.node.position, "_0")]
tree.matrix[!is.na(No),No:= paste0(abs.node.position, "_1")]
remove.tree <- . %>% stri_replace_first_regex(pattern = "^\\d+-", replacement = "")
tree.matrix[,`:=`(abs.node.position=remove.tree(abs.node.position), Yes=remove.tree(Yes), No=remove.tree(No))]
nodes.dt <- tree.matrix[,.(Quality = sum(Quality)),by = .(abs.node.position, Feature)][,.(Text =paste0(Feature[1:min(length(Feature), features_keep)], " (", Quality[1:min(length(Quality), features_keep)], ")") %>% paste0(collapse = "\n")), by=abs.node.position]
edges.dt <- tree.matrix[Feature != "Leaf",.(abs.node.position, Yes)] %>% list(tree.matrix[Feature != "Leaf",.(abs.node.position, No)]) %>% rbindlist() %>% setnames(c("From", "To")) %>% .[,.N,.(From, To)] %>% .[,N:=NULL]
nodes <- DiagrammeR::create_nodes(nodes = nodes.dt[,abs.node.position],
label = nodes.dt[,Text],
style = "filled",
color = "DimGray",
fillcolor= "Beige",
shape = "oval",
fontname = "Helvetica"
)
edges <- DiagrammeR::create_edges(from = edges.dt[,From],
to = edges.dt[,To],
color = "DimGray",
arrowsize = "1.5",
arrowhead = "vee",
fontname = "Helvetica",
rel = "leading_to")
graph <- DiagrammeR::create_graph(nodes_df = nodes,
edges_df = edges,
graph_attrs = "rankdir = LR")
DiagrammeR::render_graph(graph, width = plot_width, height = plot_height)
}
globalVariables(
c(
".N", "N", "From", "To", "Text", "Feature", "no.nodes.abs.pos", "ID", "Yes", "No", "Tree", "yes.nodes.abs.pos", "abs.node.position"
)
)

View File

@@ -0,0 +1,81 @@
#' Plot a boosted tree model
#'
#' Read a tree model text dump and plot the model.
#'
#' @param feature_names names of each feature as a \code{character} vector. Can be extracted from a sparse matrix (see example). If model dump already contains feature names, this argument should be \code{NULL}.
#' @param model generated by the \code{xgb.train} function. Avoid the creation of a dump file.
#' @param n_first_tree limit the plot to the n first trees. If \code{NULL}, all trees of the model are plotted. Performance can be low for huge models.
#' @param plot_width the width of the diagram in pixels.
#' @param plot_height the height of the diagram in pixels.
#' @param ... currently not used.
#'
#' @return A \code{DiagrammeR} of the model.
#'
#' @details
#'
#' The content of each node is organised that way:
#'
#' \itemize{
#' \item \code{feature} value;
#' \item \code{cover}: the sum of second order gradient of training data classified to the leaf, if it is square loss, this simply corresponds to the number of instances in that branch. Deeper in the tree a node is, lower this metric will be;
#' \item \code{gain}: metric the importance of the node in the model.
#' }
#'
#' The function uses \href{http://www.graphviz.org/}{GraphViz} library for that purpose.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#'
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
#'
#' xgb.plot.tree(feature_names = colnames(agaricus.train$data), model = bst)
#'
#' @export
xgb.plot.tree <- function(feature_names = NULL, model = NULL, n_first_tree = NULL, plot_width = NULL, plot_height = NULL, ...){
check.deprecation(...)
if (class(model) != "xgb.Booster") {
stop("model: Has to be an object of class xgb.Booster model generaged by the xgb.train function.")
}
if (!requireNamespace("DiagrammeR", quietly = TRUE)) {
stop("DiagrammeR package is required for xgb.plot.tree", call. = FALSE)
}
allTrees <- xgb.model.dt.tree(feature_names = feature_names, model = model, n_first_tree = n_first_tree)
allTrees[, label:= paste0(Feature, "\nCover: ", Cover, "\nGain: ", Quality)]
allTrees[, shape:= "rectangle"][Feature == "Leaf", shape:= "oval"]
allTrees[, filledcolor:= "Beige"][Feature == "Leaf", filledcolor:= "Khaki"]
# rev is used to put the first tree on top.
nodes <- DiagrammeR::create_nodes(nodes = allTrees[,ID] %>% rev,
label = allTrees[,label] %>% rev,
style = "filled",
color = "DimGray",
fillcolor= allTrees[,filledcolor] %>% rev,
shape = allTrees[,shape] %>% rev,
data = allTrees[,Feature] %>% rev,
fontname = "Helvetica"
)
edges <- DiagrammeR::create_edges(from = allTrees[Feature != "Leaf", c(ID)] %>% rep(2),
to = allTrees[Feature != "Leaf", c(Yes, No)],
label = allTrees[Feature != "Leaf", paste("<",Split)] %>% c(rep("",nrow(allTrees[Feature != "Leaf"]))),
color = "DimGray",
arrowsize = "1.5",
arrowhead = "vee",
fontname = "Helvetica",
rel = "leading_to")
graph <- DiagrammeR::create_graph(nodes_df = nodes,
edges_df = edges,
graph_attrs = "rankdir = LR")
DiagrammeR::render_graph(graph, width = plot_width, height = plot_height)
}
# Avoid error messages during CRAN check.
# The reason is that these variables are never declared
# They are mainly column names inferred by Data.table...
globalVariables(c("Feature", "ID", "Cover", "Quality", "Split", "Yes", "No", ".", "shape", "filledcolor", "label"))

View File

@@ -3,29 +3,25 @@
#' Save xgboost model from xgboost or xgb.train
#'
#' @param model the model object.
#' @param fname the name of the binary file.
#' @param fname the name of the file to write.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' data(agaricus.test, package='xgboost')
#' train <- agaricus.train
#' test <- agaricus.test
#' bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
#' eta = 1, nround = 2,objective = "binary:logistic")
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
#' xgb.save(bst, 'xgb.model')
#' bst <- xgb.load('xgb.model')
#' pred <- predict(bst, test$data)
#' @export
#'
xgb.save <- function(model, fname) {
if (typeof(fname) != "character") {
stop("xgb.save: fname must be character")
}
if (class(model) == "xgb.Booster") {
.Call("XGBoosterSaveModel_R", model, fname, PACKAGE = "xgboost")
return(TRUE)
}
stop("xgb.save: the input must be xgb.Booster. Use xgb.DMatrix.save to save
xgb.DMatrix object.")
return(FALSE)
}
if (typeof(fname) != "character")
stop("fname must be character")
if (class(model) != "xgb.Booster")
stop("the input must be xgb.Booster. Use xgb.DMatrix.save to save xgb.DMatrix object.")
.Call("XGBoosterSaveModel_R", model$handle, fname, PACKAGE = "xgboost")
return(TRUE)
}

View File

@@ -0,0 +1,23 @@
#' Save xgboost model to R's raw vector,
#' user can call xgb.load to load the model back from raw vector
#'
#' Save xgboost model from xgboost or xgb.train
#'
#' @param model the model object.
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' data(agaricus.test, package='xgboost')
#' train <- agaricus.train
#' test <- agaricus.test
#' bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
#' raw <- xgb.save.raw(bst)
#' bst <- xgb.load(raw)
#' pred <- predict(bst, test$data)
#'
#' @export
xgb.save.raw <- function(model) {
model <- xgb.get.handle(model)
.Call("XGBoosterModelToRaw_R", model, PACKAGE = "xgboost")
}

View File

@@ -1,56 +1,183 @@
#' eXtreme Gradient Boosting Training
#'
#' The training function of xgboost
#' \code{xgb.train} is an advanced interface for training an xgboost model. The \code{xgboost} function provides a simpler interface.
#'
#' @param params the list of parameters. Commonly used ones are:
#' @param params the list of parameters.
#' The complete list of parameters is available at \url{http://xgboost.readthedocs.io/en/latest/parameter.html}.
#' Below is a shorter summary:
#'
#' 1. General Parameters
#'
#' \itemize{
#' \item \code{objective} objective function, common ones are
#' \itemize{
#' \item \code{reg:linear} linear regression
#' \item \code{binary:logistic} logistic regression for classification
#' }
#' \item \code{eta} step size of each boosting step
#' \item \code{max.depth} maximum depth of the tree
#' \item \code{nthread} number of thread used in training, if not set, all threads are used
#' \item \code{booster} which booster to use, can be \code{gbtree} or \code{gblinear}. Default: \code{gbtree}
#' \item \code{silent} 0 means printing running messages, 1 means silent mode. Default: 0
#' }
#'
#' See \url{https://github.com/tqchen/xgboost/wiki/Parameters} for
#' further details. See also demo/ for walkthrough example in R.
#' @param data takes an \code{xgb.DMatrix} as the input.
#'
#' 2. Booster Parameters
#'
#' 2.1. Parameter for Tree Booster
#'
#' \itemize{
#' \item \code{eta} control the learning rate: scale the contribution of each tree by a factor of \code{0 < eta < 1} when it is added to the current approximation. Used to prevent overfitting by making the boosting process more conservative. Lower value for \code{eta} implies larger value for \code{nrounds}: low \code{eta} value means model more robust to overfitting but slower to compute. Default: 0.3
#' \item \code{gamma} minimum loss reduction required to make a further partition on a leaf node of the tree. the larger, the more conservative the algorithm will be.
#' \item \code{max_depth} maximum depth of a tree. Default: 6
#' \item \code{min_child_weight} minimum sum of instance weight (hessian) needed in a child. If the tree partition step results in a leaf node with the sum of instance weight less than min_child_weight, then the building process will give up further partitioning. In linear regression mode, this simply corresponds to minimum number of instances needed to be in each node. The larger, the more conservative the algorithm will be. Default: 1
#' \item \code{subsample} subsample ratio of the training instance. Setting it to 0.5 means that xgboost randomly collected half of the data instances to grow trees and this will prevent overfitting. It makes computation shorter (because less data to analyse). It is advised to use this parameter with \code{eta} and increase \code{nround}. Default: 1
#' \item \code{colsample_bytree} subsample ratio of columns when constructing each tree. Default: 1
#' \item \code{num_parallel_tree} Experimental parameter. number of trees to grow per round. Useful to test Random Forest through Xgboost (set \code{colsample_bytree < 1}, \code{subsample < 1} and \code{round = 1}) accordingly. Default: 1
#' }
#'
#' 2.2. Parameter for Linear Booster
#'
#' \itemize{
#' \item \code{lambda} L2 regularization term on weights. Default: 0
#' \item \code{lambda_bias} L2 regularization term on bias. Default: 0
#' \item \code{alpha} L1 regularization term on weights. (there is no L1 reg on bias because it is not important). Default: 0
#' }
#'
#' 3. Task Parameters
#'
#' \itemize{
#' \item \code{objective} specify the learning task and the corresponding learning objective, users can pass a self-defined function to it. The default objective options are below:
#' \itemize{
#' \item \code{reg:linear} linear regression (Default).
#' \item \code{reg:logistic} logistic regression.
#' \item \code{binary:logistic} logistic regression for binary classification. Output probability.
#' \item \code{binary:logitraw} logistic regression for binary classification, output score before logistic transformation.
#' \item \code{num_class} set the number of classes. To use only with multiclass objectives.
#' \item \code{multi:softmax} set xgboost to do multiclass classification using the softmax objective. Class is represented by a number and should be from 0 to \code{num_class - 1}.
#' \item \code{multi:softprob} same as softmax, but prediction outputs a vector of ndata * nclass elements, which can be further reshaped to ndata, nclass matrix. The result contains predicted probabilities of each data point belonging to each class.
#' \item \code{rank:pairwise} set xgboost to do ranking task by minimizing the pairwise loss.
#' }
#' \item \code{base_score} the initial prediction score of all instances, global bias. Default: 0.5
#' \item \code{eval_metric} evaluation metrics for validation data. Users can pass a self-defined function to it. Default: metric will be assigned according to objective(rmse for regression, and error for classification, mean average precision for ranking). List is provided in detail section.
#' }
#'
#' @param data input dataset. \code{xgb.train} takes only an \code{xgb.DMatrix} as the input.
#' \code{xgboost}, in addition, also accepts \code{matrix}, \code{dgCMatrix}, or local data file.
#' @param nrounds the max number of iterations
#' @param watchlist what information should be printed when \code{verbose=1} or
#' \code{verbose=2}. Watchlist is used to specify validation set monitoring
#' during training. For example user can specify
#' watchlist=list(validation1=mat1, validation2=mat2) to watch
#' the performance of each round's model on mat1 and mat2
#' \code{verbose=2}. Watchlist is used to specify validation set monitoring
#' during training. For example user can specify
#' watchlist=list(validation1=mat1, validation2=mat2) to watch
#' the performance of each round's model on mat1 and mat2
#'
#' @param obj customized objective function. Returns gradient and second order
#' gradient with given prediction and dtrain,
#' gradient with given prediction and dtrain.
#' @param feval custimized evaluation function. Returns
#' \code{list(metric='metric-name', value='metric-value')} with given
#' prediction and dtrain,
#' \code{list(metric='metric-name', value='metric-value')} with given
#' prediction and dtrain.
#' @param verbose If 0, xgboost will stay silent. If 1, xgboost will print
#' information of performance. If 2, xgboost will print information of both
#'
#' information of performance. If 2, xgboost will print some additional information.
#' Setting \code{verbose > 0} automatically engages the \code{\link{cb.evaluation.log}} and
#' \code{\link{cb.print.evaluation}} callback functions.
#' @param print_every_n Print each n-th iteration evaluation messages when \code{verbose>0}.
#' Default is 1 which means all messages are printed. This parameter is passed to the
#' \code{\link{cb.print.evaluation}} callback.
#' @param early_stopping_rounds If \code{NULL}, the early stopping function is not triggered.
#' If set to an integer \code{k}, training with a validation set will stop if the performance
#' doesn't improve for \code{k} rounds.
#' Setting this parameter engages the \code{\link{cb.early.stop}} callback.
#' @param maximize If \code{feval} and \code{early_stopping_rounds} are set,
#' then this parameter must be set as well.
#' When it is \code{TRUE}, it means the larger the evaluation score the better.
#' This parameter is passed to the \code{\link{cb.early.stop}} callback.
#' @param save_period when it is non-NULL, model is saved to disk after every \code{save_period} rounds,
#' 0 means save at the end. The saving is handled by the \code{\link{cb.save.model}} callback.
#' @param save_name the name or path for periodically saved model file.
#' @param xgb_model a previously built model to continue the trainig from.
#' Could be either an object of class \code{xgb.Booster}, or its raw data, or the name of a
#' file with a previously saved model.
#' @param callbacks a list of callback functions to perform various task during boosting.
#' See \code{\link{callbacks}}. Some of the callbacks are automatically created depending on the
#' parameters' values. User can provide either existing or their own callback methods in order
#' to customize the training process.
#' @param ... other parameters to pass to \code{params}.
#' @param label vector of response values. Should not be provided when data is
#' a local data file name or an \code{xgb.DMatrix}.
#' @param missing by default is set to NA, which means that NA values should be considered as 'missing'
#' by the algorithm. Sometimes, 0 or other extreme value might be used to represent missing values.
#' This parameter is only used when input is a dense matrix.
#' @param weight a vector indicating the weight for each row of the input.
#'
#' @details
#' This is the training function for xgboost.
#' These are the training functions for \code{xgboost}.
#'
#' The \code{xgb.train} interface supports advanced features such as \code{watchlist},
#' customized objective and evaluation metric functions, therefore it is more flexible
#' than the \code{\link{xgboost}} interface.
#'
#' Parallelization is automatically enabled if OpenMP is present.
#' Number of threads can also be manually specified via "nthread" parameter.
#' Parallelization is automatically enabled if \code{OpenMP} is present.
#' Number of threads can also be manually specified via \code{nthread} parameter.
#'
#' This function only accepts an \code{xgb.DMatrix} object as the input.
#' It supports advanced features such as watchlist, customized objective function,
#' therefore it is more flexible than \code{\link{xgboost}}.
#' The evaluation metric is chosen automatically by Xgboost (according to the objective)
#' when the \code{eval_metric} parameter is not provided.
#' User may set one or several \code{eval_metric} parameters.
#' Note that when using a customized metric, only this single metric can be used.
#' The folloiwing is the list of built-in metrics for which Xgboost provides optimized implementation:
#' \itemize{
#' \item \code{rmse} root mean square error. \url{http://en.wikipedia.org/wiki/Root_mean_square_error}
#' \item \code{logloss} negative log-likelihood. \url{http://en.wikipedia.org/wiki/Log-likelihood}
#' \item \code{mlogloss} multiclass logloss. \url{https://www.kaggle.com/wiki/MultiClassLogLoss}
#' \item \code{error} Binary classification error rate. It is calculated as \code{(# wrong cases) / (# all cases)}.
#' By default, it uses the 0.5 threshold for predicted values to define negative and positive instances.
#' Different threshold (e.g., 0.) could be specified as "error@0."
#' \item \code{merror} Multiclass classification error rate. It is calculated as \code{(# wrong cases) / (# all cases)}.
#' \item \code{auc} Area under the curve. \url{http://en.wikipedia.org/wiki/Receiver_operating_characteristic#'Area_under_curve} for ranking evaluation.
#' \item \code{ndcg} Normalized Discounted Cumulative Gain (for ranking task). \url{http://en.wikipedia.org/wiki/NDCG}
#' }
#'
#' The following callbacks are automatically created when certain parameters are set:
#' \itemize{
#' \item \code{cb.print.evaluation} is turned on when \code{verbose > 0};
#' and the \code{print_every_n} parameter is passed to it.
#' \item \code{cb.evaluation.log} is on when \code{verbose > 0} and \code{watchlist} is present.
#' \item \code{cb.early.stop}: when \code{early_stopping_rounds} is set.
#' \item \code{cb.save.model}: when \code{save_period > 0} is set.
#' }
#'
#' @return
#' An object of class \code{xgb.Booster} with the following elements:
#' \itemize{
#' \item \code{handle} a handle (pointer) to the xgboost model in memory.
#' \item \code{raw} a cached memory dump of the xgboost model saved as R's \code{raw} type.
#' \item \code{niter} number of boosting iterations.
#' \item \code{evaluation_log} evaluation history storead as a \code{data.table} with the
#' first column corresponding to iteration number and the rest corresponding to evaluation
#' metrics' values. It is created by the \code{\link{cb.evaluation.log}} callback.
#' \item \code{call} a function call.
#' \item \code{params} parameters that were passed to the xgboost library. Note that it does not
#' capture parameters changed by the \code{\link{cb.reset.parameters}} callback.
#' \item \code{callbacks} callback functions that were either automatically assigned or
#' explicitely passed.
#' \item \code{best_iteration} iteration number with the best evaluation metric value
#' (only available with early stopping).
#' \item \code{best_ntreelimit} the \code{ntreelimit} value corresponding to the best iteration,
#' which could further be used in \code{predict} method
#' (only available with early stopping).
#' \item \code{best_score} the best evaluation metric value during early stopping.
#' (only available with early stopping).
#' }
#'
#' @seealso
#' \code{\link{callbacks}},
#' \code{\link{predict.xgb.Booster}},
#' \code{\link{xgb.cv}}
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' data(agaricus.test, package='xgboost')
#'
#' dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)
#' dtest <- dtrain
#' dtest <- xgb.DMatrix(agaricus.test$data, label = agaricus.test$label)
#' watchlist <- list(eval = dtest, train = dtrain)
#' param <- list(max.depth = 2, eta = 1, silent = 1)
#'
#' ## A simple xgb.train example:
#' param <- list(max_depth = 2, eta = 1, silent = 1,
#' objective = "binary:logistic", eval_metric = "auc")
#' bst <- xgb.train(param, dtrain, nthread = 2, nrounds = 2, watchlist)
#'
#' ## An xgb.train example where custom objective and evaluation metric are used:
#' logregobj <- function(preds, dtrain) {
#' labels <- getinfo(dtrain, "label")
#' preds <- 1/(1 + exp(-preds))
@@ -63,36 +190,145 @@
#' err <- as.numeric(sum(labels != (preds > 0)))/length(labels)
#' return(list(metric = "error", value = err))
#' }
#' bst <- xgb.train(param, dtrain, nround = 2, watchlist, logregobj, evalerror)
#' @export
#' bst <- xgb.train(param, dtrain, nthread = 2, nrounds = 2, watchlist)
#'
xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
obj = NULL, feval = NULL, verbose = 1, ...) {
dtrain <- data
if (typeof(params) != "list") {
stop("xgb.train: first argument params must be list")
}
if (class(dtrain) != "xgb.DMatrix") {
stop("xgb.train: second argument dtrain must be xgb.DMatrix")
}
if (verbose > 1) {
params <- append(params, list(silent = 0))
} else {
params <- append(params, list(silent = 1))
}
if (length(watchlist) != 0 && verbose == 0) {
warning('watchlist is provided but verbose=0, no evaluation information will be printed')
watchlist <- list()
}
params = append(params, list(...))
#' ## An xgb.train example of using variable learning rates at each iteration:
#' my_etas <- list(eta = c(0.5, 0.1))
#' bst <- xgb.train(param, dtrain, nthread = 2, nrounds = 2, watchlist,
#' callbacks = list(cb.reset.parameters(my_etas)))
#'
#' ## Explicit use of the cb.evaluation.log callback allows to run
#' ## xgb.train silently but still store the evaluation results:
#' bst <- xgb.train(param, dtrain, nthread = 2, nrounds = 2, watchlist,
#' verbose = 0, callbacks = list(cb.evaluation.log()))
#' print(bst$evaluation_log)
#'
#' ## An 'xgboost' interface example:
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label,
#' max_depth = 2, eta = 1, nthread = 2, nrounds = 2,
#' objective = "binary:logistic")
#' pred <- predict(bst, agaricus.test$data)
#'
#' @rdname xgb.train
#' @export
xgb.train <- function(params = list(), data, nrounds, watchlist = list(),
obj = NULL, feval = NULL, verbose = 1, print_every_n=1L,
early_stopping_rounds = NULL, maximize = NULL,
save_period = NULL, save_name = "xgboost.model",
xgb_model = NULL, callbacks = list(), ...) {
bst <- xgb.Booster(params, append(watchlist, dtrain))
for (i in 1:nrounds) {
succ <- xgb.iter.update(bst, dtrain, i - 1, obj)
if (length(watchlist) != 0) {
msg <- xgb.iter.eval(bst, watchlist, i - 1, feval)
cat(paste(msg, "\n", sep=""))
check.deprecation(...)
params <- check.booster.params(params, ...)
check.custom.obj()
check.custom.eval()
# data & watchlist checks
dtrain <- data
if (class(dtrain) != "xgb.DMatrix")
stop("second argument dtrain must be xgb.DMatrix")
if (length(watchlist) > 0) {
if (typeof(watchlist) != "list" ||
!all(sapply(watchlist, class) == "xgb.DMatrix"))
stop("watchlist must be a list of xgb.DMatrix elements")
evnames <- names(watchlist)
if (is.null(evnames) || any(evnames == ""))
stop("each element of the watchlist must have a name tag")
}
# evaluation printing callback
params <- c(params, list(silent = ifelse(verbose > 1, 0, 1)))
print_every_n <- max( as.integer(print_every_n), 1L)
if (!has.callbacks(callbacks, 'cb.print.evaluation') && verbose) {
callbacks <- add.cb(callbacks, cb.print.evaluation(print_every_n))
}
# evaluation log callback: it is automatically enabled only when verbose > 0
evaluation_log <- list()
if (verbose > 0 &&
!has.callbacks(callbacks, 'cb.evaluation.log') &&
length(watchlist) > 0) {
callbacks <- add.cb(callbacks, cb.evaluation.log())
}
# Model saving callback
if (!is.null(save_period) &&
!has.callbacks(callbacks, 'cb.save.model')) {
callbacks <- add.cb(callbacks, cb.save.model(save_period, save_name))
}
# Early stopping callback
stop_condition <- FALSE
if (!is.null(early_stopping_rounds) &&
!has.callbacks(callbacks, 'cb.early.stop')) {
callbacks <- add.cb(callbacks, cb.early.stop(early_stopping_rounds,
maximize=maximize, verbose=verbose))
}
# Sort the callbacks into categories
cb <- categorize.callbacks(callbacks)
# Construct a booster (either a new one or load from xgb_model)
handle <- xgb.Booster(params, append(watchlist, dtrain), xgb_model)
bst <- xgb.handleToBooster(handle)
# extract parameters that can affect the relationship b/w #trees and #iterations
num_class <- max(as.numeric(NVL(params[['num_class']], 1)), 1)
num_parallel_tree <- max(as.numeric(NVL(params[['num_parallel_tree']], 1)), 1)
# When the 'xgb_model' was set, find out how many boosting iterations it has
niter_skip <- 0
if (!is.null(xgb_model)) {
niter_skip <- as.numeric(xgb.attr(bst, 'niter')) + 1
if (length(niter_skip) == 0) {
niter_skip <- xgb.ntree(bst) %/% (num_parallel_tree * num_class)
}
}
# TODO: distributed code
rank <- 0
begin_iteration <- niter_skip + 1
end_iteration <- niter_skip + nrounds
# the main loop for boosting iterations
for (iteration in begin_iteration:end_iteration) {
for (f in cb$pre_iter) f()
xgb.iter.update(bst$handle, dtrain, iteration - 1, obj)
bst_evaluation <- numeric(0)
if (length(watchlist) > 0)
bst_evaluation <- xgb.iter.eval(bst$handle, watchlist, iteration - 1, feval)
xgb.attr(bst$handle, 'niter') <- iteration - 1
for (f in cb$post_iter) f()
if (stop_condition) break
}
for (f in cb$finalize) f(finalize=TRUE)
bst <- xgb.Booster.check(bst, saveraw = TRUE)
# store the total number of boosting iterations
bst$niter = end_iteration
# store the evaluation results
if (length(evaluation_log) > 0 &&
nrow(evaluation_log) > 0) {
# include the previous compatible history when available
if (class(xgb_model) == 'xgb.Booster' &&
!is.null(xgb_model$evaluation_log) &&
all.equal(colnames(evaluation_log),
colnames(xgb_model$evaluation_log))) {
evaluation_log <- rbindlist(list(xgb_model$evaluation_log, evaluation_log))
}
bst$evaluation_log <- evaluation_log
}
bst$call <- match.call()
bst$params <- params
bst$callbacks <- callbacks
return(bst)
}
}

View File

@@ -1,64 +1,27 @@
#' eXtreme Gradient Boosting (Tree) library
#'
#' A simple interface for xgboost in R
#'
#' @param data takes \code{matrix}, \code{dgCMatrix}, local data file or
#' \code{xgb.DMatrix}.
#' @param label the response variable. User should not set this field,
# if data is local data file or \code{xgb.DMatrix}.
#' @param params the list of parameters. Commonly used ones are:
#' \itemize{
#' \item \code{objective} objective function, common ones are
#' \itemize{
#' \item \code{reg:linear} linear regression
#' \item \code{binary:logistic} logistic regression for classification
#' }
#' \item \code{eta} step size of each boosting step
#' \item \code{max.depth} maximum depth of the tree
#' \item \code{nthread} number of thread used in training, if not set, all threads are used
#' }
#'
#' See \url{https://github.com/tqchen/xgboost/wiki/Parameters} for
#' further details. See also demo/ for walkthrough example in R.
#' @param nrounds the max number of iterations
#' @param verbose If 0, xgboost will stay silent. If 1, xgboost will print
#' information of performance. If 2, xgboost will print information of both
#' performance and construction progress information
#' @param ... other parameters to pass to \code{params}.
#'
#' @details
#' This is the modeling function for xgboost.
#'
#' Parallelization is automatically enabled if OpenMP is present.
#' Number of threads can also be manually specified via "nthread" parameter
#'
#' @examples
#' data(agaricus.train, package='xgboost')
#' data(agaricus.test, package='xgboost')
#' train <- agaricus.train
#' test <- agaricus.test
#' bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
#' eta = 1, nround = 2,objective = "binary:logistic")
#' pred <- predict(bst, test$data)
#'
# Simple interface for training an xgboost model.
# Its documentation is combined with xgb.train.
#
#' @rdname xgb.train
#' @export
#'
xgboost <- function(data = NULL, label = NULL, params = list(), nrounds,
verbose = 1, ...) {
dtrain <- xgb.get.DMatrix(data, label)
params <- append(params, list(...))
if (verbose > 0) {
watchlist <- list(train = dtrain)
} else {
watchlist <- list()
}
bst <- xgb.train(params, dtrain, nrounds, watchlist, verbose=verbose)
return(bst)
}
xgboost <- function(data = NULL, label = NULL, missing = NA, weight = NULL,
params = list(), nrounds,
verbose = 1, print_every_n = 1L,
early_stopping_rounds = NULL, maximize = NULL,
save_period = 0, save_name = "xgboost.model",
xgb_model = NULL, callbacks = list(), ...) {
dtrain <- xgb.get.DMatrix(data, label, missing, weight)
watchlist <- list()
if (verbose > 0)
watchlist$train = dtrain
bst <- xgb.train(params, dtrain, nrounds, watchlist, verbose = verbose, print_every_n=print_every_n,
early_stopping_rounds = early_stopping_rounds, maximize = maximize,
save_period = save_period, save_name = save_name,
xgb_model = xgb_model, callbacks = callbacks, ...)
return(bst)
}
#' Training part from Mushroom Data Set
#'
@@ -69,7 +32,7 @@ xgboost <- function(data = NULL, label = NULL, params = list(), nrounds,
#'
#' \itemize{
#' \item \code{label} the label for each record
#' \item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 127 columns.
#' \item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 126 columns.
#' }
#'
#' @references
@@ -96,7 +59,7 @@ NULL
#'
#' \itemize{
#' \item \code{label} the label for each record
#' \item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 127 columns.
#' \item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 126 columns.
#' }
#'
#' @references
@@ -111,5 +74,31 @@ NULL
#' @name agaricus.test
#' @usage data(agaricus.test)
#' @format A list containing a label vector, and a dgCMatrix object with 1611
#' rows and 127 variables
#' rows and 126 variables
NULL
# Various imports
#' @importClassesFrom Matrix dgCMatrix dgeMatrix
#' @importFrom Matrix cBind
#' @importFrom Matrix colSums
#' @importFrom Matrix sparse.model.matrix
#' @importFrom Matrix sparseVector
#' @importFrom data.table data.table
#' @importFrom data.table as.data.table
#' @importFrom data.table :=
#' @importFrom data.table rbindlist
#' @importFrom data.table setkey
#' @importFrom data.table setkeyv
#' @importFrom data.table setnames
#' @importFrom magrittr %>%
#' @importFrom stringi stri_detect_regex
#' @importFrom stringi stri_match_first_regex
#' @importFrom stringi stri_replace_first_regex
#' @importFrom stringi stri_replace_all_regex
#' @importFrom stringi stri_split_regex
#' @importFrom utils object.size str tail
#' @importFrom stats predict
#'
#' @import methods
#' @useDynLib xgboost
NULL

View File

@@ -1,21 +1,73 @@
# R package for xgboost.
XGBoost R Package for Scalable GBM
==================================
## Installation
[![CRAN Status Badge](http://www.r-pkg.org/badges/version/xgboost)](http://cran.r-project.org/web/packages/xgboost)
[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/xgboost)](http://cran.rstudio.com/web/packages/xgboost/index.html)
[![Documentation Status](https://readthedocs.org/projects/xgboost/badge/?version=latest)](http://xgboost.readthedocs.org/en/latest/R-package/index.html)
For up-to-date version(which is recommended), please install from github. Windows user will need to install [RTools](http://cran.r-project.org/bin/windows/Rtools/) first.
Resources
---------
* [XGBoost R Package Online Documentation](http://xgboost.readthedocs.org/en/latest/R-package/index.html)
- Check this out for detailed documents, examples and tutorials.
```r
require(devtools)
install_github('xgboost','tqchen',subdir='R-package')
```
Installation
------------
For stable version on CRAN, please run
We are [on CRAN](https://cran.r-project.org/web/packages/xgboost/index.html) now. For stable/pre-compiled(for Windows and OS X) version, please install from CRAN:
```r
install.packages('xgboost')
```
## Examples
You can also install from our weekly updated drat repo:
```r
install.packages("drat", repos="https://cran.rstudio.com")
drat:::addRepo("dmlc")
install.packages("xgboost", repos="http://dmlc.ml/drat/", type="source")
```
* Please visit [walk through example](https://github.com/tqchen/xgboost/blob/master/R-package/demo).
* See also the [example scripts](https://github.com/tqchen/xgboost/tree/master/demo/kaggle-higgs) for Kaggle Higgs Challenge, including [speedtest script](https://github.com/tqchen/xgboost/blob/master/demo/kaggle-higgs/speedtest.R) on this dataset.
***Important*** Due to the usage of submodule, `install_github` is no longer support to install the
latest version of R package.
For up-to-date version, please install from github.
Windows users will need to install [RTools](http://cran.r-project.org/bin/windows/Rtools/) first. They also need to download [MinGW-W64](http://iweb.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe) using x86_64 architecture during installation.
Run the following command to add MinGW to PATH in Windows if not already added.
```cmd
PATH %PATH%;C:\Program Files\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\mingw64\bin
```
To compile xgboost at the root of your storage, run the following bash script.
```bash
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
git submodule init
git submodule update
alias make='mingw32-make'
cd dmlc-core
make -j4
cd ../rabit
make lib/librabit_empty.a -j4
cd ..
cp make/mingw64.mk config.mk
make -j4
```
Run the following R script to install xgboost package from the root directory.
```r
install.package('devtools') # if not installed
setwd('C:/xgboost/')
library(devtools)
install('R-package')
```
For more detailed installation instructions, please see [here](http://xgboost.readthedocs.org/en/latest/build.html#r-package-installation).
Examples
--------
* Please visit [walk through example](demo).
* See also the [example scripts](../demo/kaggle-higgs) for Kaggle Higgs Challenge, including [speedtest script](../demo/kaggle-higgs/speedtest.R) on this dataset and the one related to [Otto challenge](../demo/kaggle-otto), including a [RMarkdown documentation](../demo/kaggle-otto/understandingXGBoostModel.Rmd).

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,11 @@
basic_walkthrough Basic feature walkthrough
caret_wrapper Use xgboost to train in caret library
custom_objective Cutomize loss function, and evaluation metric
boost_from_prediction Boosting from existing prediction
predict_first_ntree Predicting using first n trees
generalized_linear_model Generalized Linear Model
cross_validation Cross validation
create_sparse_matrix Create Sparse Matrix
predict_leaf_indices Predicting the corresponding leaves
early_stopping Early Stop in training
poisson_regression Poisson Regression on count data

View File

@@ -1,11 +1,13 @@
XGBoost R Feature Walkthrough
====
* [Basic walkthrough of wrappers](basic_walkthrough.R)
* [Basic walkthrough of wrappers](basic_walkthrough.R)
* [Train a xgboost model from caret library](caret_wrapper.R)
* [Cutomize loss function, and evaluation metric](custom_objective.R)
* [Boosting from existing prediction](boost_from_prediction.R)
* [Predicting using first n trees](predict_first_ntree.R)
* [Generalized Linear Model](generalized_linear_model.R)
* [Cross validation](cross_validation.R)
* [Create a sparse matrix from a dense one](create_sparse_matrix.R)
Benchmarks
====
@@ -13,5 +15,5 @@ Benchmarks
Notes
====
* Contribution of exampls, benchmarks is more than welcomed!
* Contribution of examples, benchmarks is more than welcomed!
* If you like to share how you use xgboost to solve your problem, send a pull request:)

View File

@@ -1,7 +1,8 @@
require(xgboost)
require(methods)
# we load in the agaricus dataset
# In this example, we are aiming to predict whether a mushroom can be eated
# In this example, we are aiming to predict whether a mushroom is edible
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
@@ -12,35 +13,36 @@ class(train$data)
#-------------Basic Training using XGBoost-----------------
# this is the basic usage of xgboost you can put matrix in data field
# note: we are puting in sparse matrix here, xgboost naturally handles sparse input
# use sparse matrix when your feature is sparse(e.g. when you using one-hot encoding vector)
print("training xgboost with sparseMatrix")
bst <- xgboost(data = train$data, label = train$label, max.depth = 2, eta = 1, nround = 2,
objective = "binary:logistic")
# note: we are putting in sparse matrix here, xgboost naturally handles sparse input
# use sparse matrix when your feature is sparse(e.g. when you are using one-hot encoding vector)
print("Training xgboost with sparseMatrix")
bst <- xgboost(data = train$data, label = train$label, max_depth = 2, eta = 1, nrounds = 2,
nthread = 2, objective = "binary:logistic")
# alternatively, you can put in dense matrix, i.e. basic R-matrix
print("training xgboost with Matrix")
bst <- xgboost(data = as.matrix(train$data), label = train$label, max.depth = 2, eta = 1, nround = 2,
objective = "binary:logistic")
print("Training xgboost with Matrix")
bst <- xgboost(data = as.matrix(train$data), label = train$label, max_depth = 2, eta = 1, nrounds = 2,
nthread = 2, objective = "binary:logistic")
# you can also put in xgb.DMatrix object, stores label, data and other meta datas needed for advanced features
print("training xgboost with xgb.DMatrix")
# you can also put in xgb.DMatrix object, which stores label, data and other meta datas needed for advanced features
print("Training xgboost with xgb.DMatrix")
dtrain <- xgb.DMatrix(data = train$data, label = train$label)
bst <- xgboost(data = dtrain, max.depth = 2, eta = 1, nround = 2, objective = "binary:logistic")
bst <- xgboost(data = dtrain, max_depth = 2, eta = 1, nrounds = 2, nthread = 2,
objective = "binary:logistic")
# Verbose = 0,1,2
print ('train xgboost with verbose 0, no message')
bst <- xgboost(data = dtrain, max.depth = 2, eta = 1, nround = 2,
objective = "binary:logistic", verbose = 0)
print ('train xgboost with verbose 1, print evaluation metric')
bst <- xgboost(data = dtrain, max.depth = 2, eta = 1, nround = 2,
objective = "binary:logistic", verbose = 1)
print ('train xgboost with verbose 2, also print information about tree')
bst <- xgboost(data = dtrain, max.depth = 2, eta = 1, nround = 2,
objective = "binary:logistic", verbose = 2)
print("Train xgboost with verbose 0, no message")
bst <- xgboost(data = dtrain, max_depth = 2, eta = 1, nrounds = 2,
nthread = 2, objective = "binary:logistic", verbose = 0)
print("Train xgboost with verbose 1, print evaluation metric")
bst <- xgboost(data = dtrain, max_depth = 2, eta = 1, nrounds = 2,
nthread = 2, objective = "binary:logistic", verbose = 1)
print("Train xgboost with verbose 2, also print information about tree")
bst <- xgboost(data = dtrain, max_depth = 2, eta = 1, nrounds = 2,
nthread = 2, objective = "binary:logistic", verbose = 2)
# you can also specify data as file path to a LibSVM format input
# since we do not have this file with us, the following line is just for illustration
# bst <- xgboost(data = 'agaricus.train.svm', max.depth = 2, eta = 1, nround = 2,objective = "binary:logistic")
# bst <- xgboost(data = 'agaricus.train.svm', max_depth = 2, eta = 1, nrounds = 2,objective = "binary:logistic")
#--------------------basic prediction using xgboost--------------
# you can do prediction using the following line
@@ -58,36 +60,52 @@ pred2 <- predict(bst2, test$data)
# pred2 should be identical to pred
print(paste("sum(abs(pred2-pred))=", sum(abs(pred2-pred))))
# save model to R's raw vector
raw = xgb.save.raw(bst)
# load binary model to R
bst3 <- xgb.load(raw)
pred3 <- predict(bst3, test$data)
# pred3 should be identical to pred
print(paste("sum(abs(pred3-pred))=", sum(abs(pred3-pred))))
#----------------Advanced features --------------
# to use advanced features, we need to put data in xgb.DMatrix
dtrain <- xgb.DMatrix(data = train$data, label=train$label)
dtest <- xgb.DMatrix(data = test$data, label=test$label)
#---------------Using watchlist----------------
# watchlist is a list of xgb.DMatrix, each of them tagged with name
# watchlist is a list of xgb.DMatrix, each of them is tagged with name
watchlist <- list(train=dtrain, test=dtest)
# to train with watchlist, use xgb.train, which contains more advanced features
# watchlist allows us to monitor the evaluation result on all data in the list
print ('train xgboost using xgb.train with watchlist')
bst <- xgb.train(data=dtrain, max.depth=2, eta=1, nround=2, watchlist=watchlist,
objective = "binary:logistic")
print("Train xgboost using xgb.train with watchlist")
bst <- xgb.train(data=dtrain, max_depth=2, eta=1, nrounds=2, watchlist=watchlist,
nthread = 2, objective = "binary:logistic")
# we can change evaluation metrics, or use multiple evaluation metrics
print ('train xgboost using xgb.train with watchlist, watch logloss and error')
bst <- xgb.train(data=dtrain, max.depth=2, eta=1, nround=2, watchlist=watchlist,
eval.metric = "error", eval.metric = "logloss",
objective = "binary:logistic")
print("train xgboost using xgb.train with watchlist, watch logloss and error")
bst <- xgb.train(data=dtrain, max_depth=2, eta=1, nrounds=2, watchlist=watchlist,
eval_metric = "error", eval_metric = "logloss",
nthread = 2, objective = "binary:logistic")
# xgb.DMatrix can also be saved using xgb.DMatrix.save
xgb.DMatrix.save(dtrain, "dtrain.buffer")
# to load it in, simply call xgb.DMatrix
dtrain2 <- xgb.DMatrix("dtrain.buffer")
bst <- xgb.train(data=dtrain2, max.depth=2, eta=1, nround=2, watchlist=watchlist,
objective = "binary:logistic")
bst <- xgb.train(data=dtrain2, max_depth=2, eta=1, nrounds=2, watchlist=watchlist,
nthread = 2, objective = "binary:logistic")
# information can be extracted from xgb.DMatrix using getinfo
label = getinfo(dtest, "label")
pred <- predict(bst, dtest)
err <- as.numeric(sum(as.integer(pred > 0.5) != label))/length(label)
print(paste("test-error=", err))
# Finally, you can dump the tree you learned using xgb.dump into a text file
xgb.dump(bst, "dump.raw.txt")
# You can dump the tree you learned using xgb.dump into a text file
xgb.dump(bst, "dump.raw.txt", with_stats = T)
# Finally, you can check which features are the most important.
print("Most important features (look at column Gain):")
imp_matrix <- xgb.importance(feature_names = colnames(train$data), model = bst)
print(imp_matrix)
# Feature importance bar plot by gain
print("Feature importance Plot : ")
print(xgb.plot.importance(importance_matrix = imp_matrix))

View File

@@ -11,8 +11,8 @@ watchlist <- list(eval = dtest, train = dtrain)
#
print('start running example to start from a initial prediction')
# train xgboost for 1 round
param <- list(max.depth=2,eta=1,silent=1,objective='binary:logistic')
bst <- xgb.train( param, dtrain, 1, watchlist )
param <- list(max_depth=2, eta=1, nthread = 2, silent=1, objective='binary:logistic')
bst <- xgb.train(param, dtrain, 1, watchlist)
# Note: we need the margin value instead of transformed prediction in set_base_margin
# do predict with output_margin=TRUE, will always give you margin values before logistic transformation
ptrain <- predict(bst, dtrain, outputmargin=TRUE)
@@ -23,4 +23,4 @@ setinfo(dtrain, "base_margin", ptrain)
setinfo(dtest, "base_margin", ptest)
print('this is result of boost from initial prediction')
bst <- xgb.train( param, dtrain, 1, watchlist )
bst <- xgb.train(params = param, data = dtrain, nrounds = 1, watchlist = watchlist)

View File

@@ -0,0 +1,35 @@
# install development version of caret library that contains xgboost models
devtools::install_github("topepo/caret/pkg/caret")
require(caret)
require(xgboost)
require(data.table)
require(vcd)
require(e1071)
# Load Arthritis dataset in memory.
data(Arthritis)
# Create a copy of the dataset with data.table package (data.table is 100% compliant with R dataframe but its syntax is a lot more consistent and its performance are really good).
df <- data.table(Arthritis, keep.rownames = F)
# Let's add some new categorical features to see if it helps. Of course these feature are highly correlated to the Age feature. Usually it's not a good thing in ML, but Tree algorithms (including boosted trees) are able to select the best features, even in case of highly correlated features.
# For the first feature we create groups of age by rounding the real age. Note that we transform it to factor (categorical data) so the algorithm treat them as independant values.
df[,AgeDiscret:= as.factor(round(Age/10,0))]
# Here is an even stronger simplification of the real age with an arbitrary split at 30 years old. I choose this value based on nothing. We will see later if simplifying the information based on arbitrary values is a good strategy (I am sure you already have an idea of how well it will work!).
df[,AgeCat:= as.factor(ifelse(Age > 30, "Old", "Young"))]
# We remove ID as there is nothing to learn from this feature (it will just add some noise as the dataset is small).
df[,ID:=NULL]
#-------------Basic Training using XGBoost in caret Library-----------------
# Set up control parameters for caret::train
# Here we use 10-fold cross-validation, repeating twice, and using random search for tuning hyper-parameters.
fitControl <- trainControl(method = "cv", number = 10, repeats = 2, search = "random")
# train a xgbTree model using caret::train
model <- train(factor(Improved)~., data = df, method = "xgbTree", trControl = fitControl)
# Instead of tree for our boosters, you can also fit a linear regression or logistic regression model using xgbLinear
# model <- train(factor(Improved)~., data = df, method = "xgbLinear", trControl = fitControl)
# See model results
print(model)

View File

@@ -0,0 +1,89 @@
require(xgboost)
require(Matrix)
require(data.table)
if (!require(vcd)) {
install.packages('vcd') #Available in Cran. Used for its dataset with categorical values.
require(vcd)
}
# According to its documentation, Xgboost works only on numbers.
# Sometimes the dataset we have to work on have categorical data.
# A categorical variable is one which have a fixed number of values. By example, if for each observation a variable called "Colour" can have only "red", "blue" or "green" as value, it is a categorical variable.
#
# In R, categorical variable is called Factor.
# Type ?factor in console for more information.
#
# In this demo we will see how to transform a dense dataframe with categorical variables to a sparse matrix before analyzing it in Xgboost.
# The method we are going to see is usually called "one hot encoding".
#load Arthritis dataset in memory.
data(Arthritis)
# create a copy of the dataset with data.table package (data.table is 100% compliant with R dataframe but its syntax is a lot more consistent and its performance are really good).
df <- data.table(Arthritis, keep.rownames = F)
# Let's have a look to the data.table
cat("Print the dataset\n")
print(df)
# 2 columns have factor type, one has ordinal type (ordinal variable is a categorical variable with values wich can be ordered, here: None > Some > Marked).
cat("Structure of the dataset\n")
str(df)
# Let's add some new categorical features to see if it helps. Of course these feature are highly correlated to the Age feature. Usually it's not a good thing in ML, but Tree algorithms (including boosted trees) are able to select the best features, even in case of highly correlated features.
# For the first feature we create groups of age by rounding the real age. Note that we transform it to factor (categorical data) so the algorithm treat them as independant values.
df[,AgeDiscret:= as.factor(round(Age/10,0))]
# Here is an even stronger simplification of the real age with an arbitrary split at 30 years old. I choose this value based on nothing. We will see later if simplifying the information based on arbitrary values is a good strategy (I am sure you already have an idea of how well it will work!).
df[,AgeCat:= as.factor(ifelse(Age > 30, "Old", "Young"))]
# We remove ID as there is nothing to learn from this feature (it will just add some noise as the dataset is small).
df[,ID:=NULL]
# List the different values for the column Treatment: Placebo, Treated.
cat("Values of the categorical feature Treatment\n")
print(levels(df[,Treatment]))
# Next step, we will transform the categorical data to dummy variables.
# This method is also called one hot encoding.
# The purpose is to transform each value of each categorical feature in one binary feature.
#
# Let's take, the column Treatment will be replaced by two columns, Placebo, and Treated. Each of them will be binary. For example an observation which had the value Placebo in column Treatment before the transformation will have, after the transformation, the value 1 in the new column Placebo and the value 0 in the new column Treated.
#
# Formulae Improved~.-1 used below means transform all categorical features but column Improved to binary values.
# Column Improved is excluded because it will be our output column, the one we want to predict.
sparse_matrix = sparse.model.matrix(Improved~.-1, data = df)
cat("Encoding of the sparse Matrix\n")
print(sparse_matrix)
# Create the output vector (not sparse)
# 1. Set, for all rows, field in Y column to 0;
# 2. set Y to 1 when Improved == Marked;
# 3. Return Y column
output_vector = df[,Y:=0][Improved == "Marked",Y:=1][,Y]
# Following is the same process as other demo
cat("Learning...\n")
bst <- xgboost(data = sparse_matrix, label = output_vector, max_depth = 9,
eta = 1, nthread = 2, nrounds = 10, objective = "binary:logistic")
importance <- xgb.importance(feature_names = colnames(sparse_matrix), model = bst)
print(importance)
# According to the matrix below, the most important feature in this dataset to predict if the treatment will work is the Age. The second most important feature is having received a placebo or not. The sex is third. Then we see our generated features (AgeDiscret). We can see that their contribution is very low (Gain column).
# Does these result make sense?
# Let's check some Chi2 between each of these features and the outcome.
print(chisq.test(df$Age, df$Y))
# Pearson correlation between Age and illness disappearing is 35
print(chisq.test(df$AgeDiscret, df$Y))
# Our first simplification of Age gives a Pearson correlation of 8.
print(chisq.test(df$AgeCat, df$Y))
# The perfectly random split I did between young and old at 30 years old have a low correlation of 2. It's a result we may expect as may be in my mind > 30 years is being old (I am 32 and starting feeling old, this may explain that), but for the illness we are studying, the age to be vulnerable is not the same. Don't let your "gut" lower the quality of your model. In "data science", there is science :-)
# As you can see, in general destroying information by simplifying it won't improve your model. Chi2 just demonstrates that. But in more complex cases, creating a new feature based on existing one which makes link with the outcome more obvious may help the algorithm and improve the model. The case studied here is not enough complex to show that. Check Kaggle forum for some challenging datasets.
# However it's almost always worse when you add some arbitrary rules.
# Moreover, you can notice that even if we have added some not useful new features highly correlated with other features, the boosting tree algorithm have been able to choose the best one, which in this case is the Age. Linear model may not be that strong in these scenario.

View File

@@ -6,7 +6,7 @@ dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)
dtest <- xgb.DMatrix(agaricus.test$data, label = agaricus.test$label)
nround <- 2
param <- list(max.depth=2,eta=1,silent=1,objective='binary:logistic')
param <- list(max_depth=2, eta=1, silent=1, nthread=2, objective='binary:logistic')
cat('running cross validation\n')
# do cross validation, this will print result out as
@@ -19,7 +19,7 @@ cat('running cross validation, disable standard deviation display\n')
# [iteration] metric_name:mean_value+std_value
# std_value is standard deviation of the metric
xgb.cv(param, dtrain, nround, nfold=5,
metrics={'error'}, , showsd = FALSE)
metrics='error', showsd = FALSE)
###
# you can also do cross validation with cutomized loss function
@@ -40,8 +40,12 @@ evalerror <- function(preds, dtrain) {
return(list(metric = "error", value = err))
}
param <- list(max.depth=2,eta=1,silent=1)
param <- list(max_depth=2, eta=1, silent=1,
objective = logregobj, eval_metric = evalerror)
# train with customized objective
xgb.cv(param, dtrain, nround, nfold = 5,
obj = logregobj, feval=evalerror)
xgb.cv(params = param, data = dtrain, nrounds = nround, nfold = 5)
# do cross validation with prediction values for each fold
res <- xgb.cv(params = param, data = dtrain, nrounds = nround, nfold = 5, prediction = TRUE)
res$evaluation_log
length(res$pred)

View File

@@ -8,7 +8,6 @@ dtest <- xgb.DMatrix(agaricus.test$data, label = agaricus.test$label)
# note: for customized objective function, we leave objective as default
# note: what we are getting is margin value in prediction
# you must know what you are doing
param <- list(max.depth=2,eta=1,silent=1)
watchlist <- list(eval = dtest, train = dtrain)
num_round <- 2
@@ -33,7 +32,34 @@ evalerror <- function(preds, dtrain) {
err <- as.numeric(sum(labels != (preds > 0)))/length(labels)
return(list(metric = "error", value = err))
}
param <- list(max_depth=2, eta=1, nthread = 2, silent=1,
objective=logregobj, eval_metric=evalerror)
print ('start training with user customized objective')
# training with customized objective, we can also do step by step training
# simply look at xgboost.py's implementation of train
bst <- xgb.train(param, dtrain, num_round, watchlist, logregobj, evalerror)
bst <- xgb.train(param, dtrain, num_round, watchlist)
#
# there can be cases where you want additional information
# being considered besides the property of DMatrix you can get by getinfo
# you can set additional information as attributes if DMatrix
# set label attribute of dtrain to be label, we use label as an example, it can be anything
attr(dtrain, 'label') <- getinfo(dtrain, 'label')
# this is new customized objective, where you can access things you set
# same thing applies to customized evaluation function
logregobjattr <- function(preds, dtrain) {
# now you can access the attribute in customized function
labels <- attr(dtrain, 'label')
preds <- 1/(1 + exp(-preds))
grad <- preds - labels
hess <- preds * (1 - preds)
return(list(grad = grad, hess = hess))
}
param <- list(max_depth=2, eta=1, nthread = 2, silent=1,
objective=logregobjattr, eval_metric=evalerror)
print ('start training with user customized objective, with additional attributes in DMatrix')
# training with customized objective, we can also do step by step training
# simply look at xgboost.py's implementation of train
bst <- xgb.train(param, dtrain, num_round, watchlist)

View File

@@ -0,0 +1,40 @@
require(xgboost)
# load in the agaricus dataset
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)
dtest <- xgb.DMatrix(agaricus.test$data, label = agaricus.test$label)
# note: for customized objective function, we leave objective as default
# note: what we are getting is margin value in prediction
# you must know what you are doing
param <- list(max_depth=2, eta=1, nthread = 2, silent=1)
watchlist <- list(eval = dtest)
num_round <- 20
# user define objective function, given prediction, return gradient and second order gradient
# this is loglikelihood loss
logregobj <- function(preds, dtrain) {
labels <- getinfo(dtrain, "label")
preds <- 1/(1 + exp(-preds))
grad <- preds - labels
hess <- preds * (1 - preds)
return(list(grad = grad, hess = hess))
}
# user defined evaluation function, return a pair metric_name, result
# NOTE: when you do customized loss function, the default prediction value is margin
# this may make buildin evalution metric not function properly
# for example, we are doing logistic loss, the prediction is score before logistic transformation
# the buildin evaluation error assumes input is after logistic transformation
# Take this in mind when you use the customization, and maybe you need write customized evaluation function
evalerror <- function(preds, dtrain) {
labels <- getinfo(dtrain, "label")
err <- as.numeric(sum(labels != (preds > 0)))/length(labels)
return(list(metric = "error", value = err))
}
print ('start training with early Stopping setting')
bst <- xgb.train(param, dtrain, num_round, watchlist,
objective = logregobj, eval_metric = evalerror, maximize = FALSE,
early_stopping_round = 3)
bst <- xgb.cv(param, dtrain, num_round, nfold = 5,
objective = logregobj, eval_metric = evalerror,
maximize = FALSE, early_stopping_rounds = 3)

View File

@@ -15,7 +15,7 @@ dtest <- xgb.DMatrix(agaricus.test$data, label = agaricus.test$label)
# lambda is the L2 regularizer
# you can also set lambda_bias which is L2 regularizer on the bias term
param <- list(objective = "binary:logistic", booster = "gblinear",
alpha = 0.0001, lambda = 1)
nthread = 2, alpha = 0.0001, lambda = 1)
# normally, you do not need to set eta (step_size)
# XGBoost uses a parallel coordinate descent algorithm (shotgun),

View File

@@ -0,0 +1,7 @@
data(mtcars)
head(mtcars)
bst = xgboost(data=as.matrix(mtcars[,-11]),label=mtcars[,11],
objective='count:poisson',nrounds=5)
pred = predict(bst,as.matrix(mtcars[,-11]))
sqrt(mean((pred-mtcars[,11])^2))

View File

@@ -5,12 +5,12 @@ data(agaricus.test, package='xgboost')
dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)
dtest <- xgb.DMatrix(agaricus.test$data, label = agaricus.test$label)
param <- list(max.depth=2,eta=1,silent=1,objective='binary:logistic')
param <- list(max_depth=2, eta=1, silent=1, objective='binary:logistic')
watchlist <- list(eval = dtest, train = dtrain)
nround = 2
# training the model for two rounds
bst = xgb.train(param, dtrain, nround, watchlist)
bst = xgb.train(param, dtrain, nround, nthread = 2, watchlist)
cat('start testing prediction from first n trees\n')
labels <- getinfo(dtest,'label')

View File

@@ -0,0 +1,52 @@
require(xgboost)
require(data.table)
require(Matrix)
set.seed(1982)
# load in the agaricus dataset
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
dtrain <- xgb.DMatrix(data = agaricus.train$data, label = agaricus.train$label)
dtest <- xgb.DMatrix(data = agaricus.test$data, label = agaricus.test$label)
param <- list(max_depth=2, eta=1, silent=1, objective='binary:logistic')
nround = 4
# training the model for two rounds
bst = xgb.train(params = param, data = dtrain, nrounds = nround, nthread = 2)
# Model accuracy without new features
accuracy.before <- sum((predict(bst, agaricus.test$data) >= 0.5) == agaricus.test$label) / length(agaricus.test$label)
# by default, we predict using all the trees
pred_with_leaf = predict(bst, dtest, predleaf = TRUE)
head(pred_with_leaf)
create.new.tree.features <- function(model, original.features){
pred_with_leaf <- predict(model, original.features, predleaf = TRUE)
cols <- list()
for(i in 1:length(trees)){
# max is not the real max but it s not important for the purpose of adding features
leaf.id <- sort(unique(pred_with_leaf[,i]))
cols[[i]] <- factor(x = pred_with_leaf[,i], level = leaf.id)
}
cBind(original.features, sparse.model.matrix( ~ . -1, as.data.frame(cols)))
}
# Convert previous features to one hot encoding
new.features.train <- create.new.tree.features(bst, agaricus.train$data)
new.features.test <- create.new.tree.features(bst, agaricus.test$data)
# learning with new features
new.dtrain <- xgb.DMatrix(data = new.features.train, label = agaricus.train$label)
new.dtest <- xgb.DMatrix(data = new.features.test, label = agaricus.test$label)
watchlist <- list(train = new.dtrain)
bst <- xgb.train(params = param, data = new.dtrain, nrounds = nround, nthread = 2)
# Model accuracy with new features
accuracy.after <- sum((predict(bst, new.dtest) >= 0.5) == agaricus.test$label) / length(agaricus.test$label)
# Here the accuracy was already good and is now perfect.
cat(paste("The accuracy was", accuracy.before, "before adding leaf features and it is now", accuracy.after, "!\n"))

View File

@@ -5,4 +5,8 @@ demo(boost_from_prediction)
demo(predict_first_ntree)
demo(generalized_linear_model)
demo(cross_validation)
demo(create_sparse_matrix)
demo(predict_leaf_indices)
demo(early_stopping)
demo(poisson_regression)
demo(caret_wrapper)

View File

@@ -1,10 +1,11 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgboost.R
\docType{data}
\name{agaricus.test}
\alias{agaricus.test}
\title{Test part from Mushroom Data Set}
\format{A list containing a label vector, and a dgCMatrix object with 1611
rows and 127 variables}
\format{A list containing a label vector, and a dgCMatrix object with 1611
rows and 126 variables}
\usage{
data(agaricus.test)
}
@@ -17,14 +18,14 @@ This data set includes the following fields:
\itemize{
\item \code{label} the label for each record
\item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 127 columns.
\item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 126 columns.
}
}
\references{
https://archive.ics.uci.edu/ml/datasets/Mushroom
Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository
[http://archive.ics.uci.edu/ml]. Irvine, CA: University of California,
Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository
[http://archive.ics.uci.edu/ml]. Irvine, CA: University of California,
School of Information and Computer Science.
}
\keyword{datasets}

View File

@@ -1,9 +1,10 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgboost.R
\docType{data}
\name{agaricus.train}
\alias{agaricus.train}
\title{Training part from Mushroom Data Set}
\format{A list containing a label vector, and a dgCMatrix object with 6513
\format{A list containing a label vector, and a dgCMatrix object with 6513
rows and 127 variables}
\usage{
data(agaricus.train)
@@ -17,14 +18,14 @@ This data set includes the following fields:
\itemize{
\item \code{label} the label for each record
\item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 127 columns.
\item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 126 columns.
}
}
\references{
https://archive.ics.uci.edu/ml/datasets/Mushroom
Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository
[http://archive.ics.uci.edu/ml]. Irvine, CA: University of California,
Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository
[http://archive.ics.uci.edu/ml]. Irvine, CA: University of California,
School of Information and Computer Science.
}
\keyword{datasets}

View File

@@ -0,0 +1,38 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/callbacks.R
\name{callbacks}
\alias{callbacks}
\title{Callback closures for booster training.}
\description{
These are used to perform various service tasks either during boosting iterations or at the end.
This approach helps to modularize many of such tasks without bloating the main training methods,
and it offers .
}
\details{
By default, a callback function is run after each boosting iteration.
An R-attribute \code{is_pre_iteration} could be set for a callback to define a pre-iteration function.
When a callback function has \code{finalize} parameter, its finalizer part will also be run after
the boosting is completed.
WARNING: side-effects!!! Be aware that these callback functions access and modify things in
the environment from which they are called from, which is a fairly uncommon thing to do in R.
To write a custom callback closure, make sure you first understand the main concepts about R envoronments.
Check either R documentation on \code{\link[base]{environment}} or the
\href{http://adv-r.had.co.nz/Environments.html}{Environments chapter} from the "Advanced R"
book by Hadley Wickham. Further, the best option is to read the code of some of the existing callbacks -
choose ones that do something similar to what you want to achieve. Also, you would need to get familiar
with the objects available inside of the \code{xgb.train} and \code{xgb.cv} internal environments.
}
\seealso{
\code{\link{cb.print.evaluation}},
\code{\link{cb.evaluation.log}},
\code{\link{cb.reset.parameters}},
\code{\link{cb.early.stop}},
\code{\link{cb.save.model}},
\code{\link{cb.cv.predict}},
\code{\link{xgb.train}},
\code{\link{xgb.cv}}
}

View File

@@ -0,0 +1,43 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/callbacks.R
\name{cb.cv.predict}
\alias{cb.cv.predict}
\title{Callback closure for returning cross-validation based predictions.}
\usage{
cb.cv.predict(save_models = FALSE)
}
\arguments{
\item{save_models}{a flag for whether to save the folds' models.}
}
\value{
Predictions are returned inside of the \code{pred} element, which is either a vector or a matrix,
depending on the number of prediction outputs per data row. The order of predictions corresponds
to the order of rows in the original dataset. Note that when a custom \code{folds} list is
provided in \code{xgb.cv}, the predictions would only be returned properly when this list is a
non-overlapping list of k sets of indices, as in a standard k-fold CV. The predictions would not be
meaningful when user-profided folds have overlapping indices as in, e.g., random sampling splits.
When some of the indices in the training dataset are not included into user-provided \code{folds},
their prediction value would be \code{NA}.
}
\description{
Callback closure for returning cross-validation based predictions.
}
\details{
This callback function saves predictions for all of the test folds,
and also allows to save the folds' models.
It is a "finalizer" callback and it uses early stopping information whenever it is available,
thus it must be run after the early stopping callback if the early stopping is used.
Callback function expects the following values to be set in its calling frame:
\code{bst_folds},
\code{basket},
\code{data},
\code{end_iteration},
\code{num_parallel_tree},
\code{num_class}.
}
\seealso{
\code{\link{callbacks}}
}

View File

@@ -0,0 +1,63 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/callbacks.R
\name{cb.early.stop}
\alias{cb.early.stop}
\title{Callback closure to activate the early stopping.}
\usage{
cb.early.stop(stopping_rounds, maximize = FALSE, metric_name = NULL,
verbose = TRUE)
}
\arguments{
\item{stopping_rounds}{The number of rounds with no improvement in
the evaluation metric in order to stop the training.}
\item{maximize}{whether to maximize the evaluation metric}
\item{metric_name}{the name of an evaluation column to use as a criteria for early
stopping. If not set, the last column would be used.
Let's say the test data in \code{watchlist} was labelled as \code{dtest},
and one wants to use the AUC in test data for early stopping regardless of where
it is in the \code{watchlist}, then one of the following would need to be set:
\code{metric_name='dtest-auc'} or \code{metric_name='dtest_auc'}.
All dash '-' characters in metric names are considered equivalent to '_'.}
\item{verbose}{whether to print the early stopping information.}
}
\description{
Callback closure to activate the early stopping.
}
\details{
This callback function determines the condition for early stopping
by setting the \code{stop_condition = TRUE} flag in its calling frame.
The following additional fields are assigned to the model's R object:
\itemize{
\item \code{best_score} the evaluation score at the best iteration
\item \code{best_iteration} at which boosting iteration the best score has occurred (1-based index)
\item \code{best_ntreelimit} to use with the \code{ntreelimit} parameter in \code{predict}.
It differs from \code{best_iteration} in multiclass or random forest settings.
}
The Same values are also stored as xgb-attributes:
\itemize{
\item \code{best_iteration} is stored as a 0-based iteration index (for interoperability of binary models)
\item \code{best_msg} message string is also stored.
}
At least one data element is required in the evaluation watchlist for early stopping to work.
Callback function expects the following values to be set in its calling frame:
\code{stop_condition},
\code{bst_evaluation},
\code{rank},
\code{bst} (or \code{bst_folds} and \code{basket}),
\code{iteration},
\code{begin_iteration},
\code{end_iteration},
\code{num_parallel_tree}.
}
\seealso{
\code{\link{callbacks}},
\code{\link{xgb.attr}}
}

View File

@@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/callbacks.R
\name{cb.evaluation.log}
\alias{cb.evaluation.log}
\title{Callback closure for logging the evaluation history}
\usage{
cb.evaluation.log()
}
\description{
Callback closure for logging the evaluation history
}
\details{
This callback function appends the current iteration evaluation results \code{bst_evaluation}
available in the calling parent frame to the \code{evaluation_log} list in a calling frame.
The finalizer callback (called with \code{finalize = TURE} in the end) converts
the \code{evaluation_log} list into a final data.table.
The iteration evaluation result \code{bst_evaluation} must be a named numeric vector.
Note: in the column names of the final data.table, the dash '-' character is replaced with
the underscore '_' in order to make the column names more like regular R identifiers.
Callback function expects the following values to be set in its calling frame:
\code{evaluation_log},
\code{bst_evaluation},
\code{iteration}.
}
\seealso{
\code{\link{callbacks}}
}

View File

@@ -0,0 +1,28 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/callbacks.R
\name{cb.print.evaluation}
\alias{cb.print.evaluation}
\title{Callback closure for printing the result of evaluation}
\usage{
cb.print.evaluation(period = 1)
}
\arguments{
\item{period}{results would be printed every number of periods}
}
\description{
Callback closure for printing the result of evaluation
}
\details{
The callback function prints the result of evaluation at every \code{period} iterations.
The initial and the last iteration's evaluations are always printed.
Callback function expects the following values to be set in its calling frame:
\code{bst_evaluation} (also \code{bst_evaluation_err} when available),
\code{iteration},
\code{begin_iteration},
\code{end_iteration}.
}
\seealso{
\code{\link{callbacks}}
}

View File

@@ -0,0 +1,37 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/callbacks.R
\name{cb.reset.parameters}
\alias{cb.reset.parameters}
\title{Callback closure for restetting the booster's parameters at each iteration.}
\usage{
cb.reset.parameters(new_params)
}
\arguments{
\item{new_params}{a list where each element corresponds to a parameter that needs to be reset.
Each element's value must be either a vector of values of length \code{nrounds}
to be set at each iteration,
or a function of two parameters \code{learning_rates(iteration, nrounds)}
which returns a new parameter value by using the current iteration number
and the total number of boosting rounds.}
}
\description{
Callback closure for restetting the booster's parameters at each iteration.
}
\details{
This is a "pre-iteration" callback function used to reset booster's parameters
at the beginning of each iteration.
Note that when training is resumed from some previous model, and a function is used to
reset a parameter value, the \code{nround} argument in this function would be the
the number of boosting rounds in the current training.
Callback function expects the following values to be set in its calling frame:
\code{bst} or \code{bst_folds},
\code{iteration},
\code{begin_iteration},
\code{end_iteration}.
}
\seealso{
\code{\link{callbacks}}
}

View File

@@ -0,0 +1,34 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/callbacks.R
\name{cb.save.model}
\alias{cb.save.model}
\title{Callback closure for saving a model file.}
\usage{
cb.save.model(save_period = 0, save_name = "xgboost.model")
}
\arguments{
\item{save_period}{save the model to disk after every
\code{save_period} iterations; 0 means save the model at the end.}
\item{save_name}{the name or path for the saved model file.
It can contain a \code{\link[base]{sprintf}} formatting specifier
to include the integer iteration number in the file name.
E.g., with \code{save_name} = 'xgboost_%04d.model',
the file saved at iteration 50 would be named "xgboost_0050.model".}
}
\description{
Callback closure for saving a model file.
}
\details{
This callback function allows to save an xgb-model file, either periodically after each \code{save_period}'s or at the end.
Callback function expects the following values to be set in its calling frame:
\code{bst},
\code{iteration},
\code{begin_iteration},
\code{end_iteration}.
}
\seealso{
\code{\link{callbacks}}
}

View File

@@ -0,0 +1,29 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.DMatrix.R
\name{dim.xgb.DMatrix}
\alias{dim.xgb.DMatrix}
\title{Dimensions of xgb.DMatrix}
\usage{
\method{dim}{xgb.DMatrix}(x)
}
\arguments{
\item{x}{Object of class \code{xgb.DMatrix}}
}
\description{
Returns a vector of numbers of rows and of columns in an \code{xgb.DMatrix}.
}
\details{
Note: since \code{nrow} and \code{ncol} internally use \code{dim}, they can also
be directly used with an \code{xgb.DMatrix} object.
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)
stopifnot(nrow(dtrain) == nrow(train$data))
stopifnot(ncol(dtrain) == ncol(train$data))
stopifnot(all(dim(dtrain) == dim(train$data)))
}

View File

@@ -0,0 +1,36 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.DMatrix.R
\name{dimnames.xgb.DMatrix}
\alias{dimnames.xgb.DMatrix}
\alias{dimnames<-.xgb.DMatrix}
\title{Handling of column names of \code{xgb.DMatrix}}
\usage{
\method{dimnames}{xgb.DMatrix}(x)
\method{dimnames}{xgb.DMatrix}(x) <- value
}
\arguments{
\item{x}{object of class \code{xgb.DMatrix}}
\item{value}{a list of two elements: the first one is ignored
and the second one is column names}
}
\description{
Only column names are supported for \code{xgb.DMatrix}, thus setting of
row names would have no effect and returnten row names would be NULL.
}
\details{
Generic \code{dimnames} methods are used by \code{colnames}.
Since row names are irrelevant, it is recommended to use \code{colnames} directly.
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)
dimnames(dtrain)
colnames(dtrain)
colnames(dtrain) <- make.names(1:ncol(train$data))
print(dtrain, verbose=TRUE)
}

View File

@@ -1,30 +1,42 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{methods}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.DMatrix.R
\name{getinfo}
\alias{getinfo}
\alias{getinfo,xgb.DMatrix-method}
\alias{getinfo.xgb.DMatrix}
\title{Get information of an xgb.DMatrix object}
\usage{
getinfo(object, ...)
\S4method{getinfo}{xgb.DMatrix}(object, name)
\method{getinfo}{xgb.DMatrix}(object, name, ...)
}
\arguments{
\item{object}{Object of class "xgb.DMatrix"}
\item{name}{the name of the field to get}
\item{object}{Object of class \code{xgb.DMatrix}}
\item{...}{other parameters}
\item{name}{the name of the information field to get (see details)}
}
\description{
Get information of an xgb.DMatrix object
}
\details{
The \code{name} field can be one of the following:
\itemize{
\item \code{label}: label Xgboost learn from ;
\item \code{weight}: to do a weight rescale ;
\item \code{base_margin}: base margin is the base prediction Xgboost will boost from ;
\item \code{nrow}: number of rows of the \code{xgb.DMatrix}.
}
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)
labels <- getinfo(dtrain, 'label')
setinfo(dtrain, 'label', 1-labels)
labels2 <- getinfo(dtrain, 'label')
stopifnot(all(labels2 == 1-labels))
}

View File

@@ -1,37 +0,0 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{methods}
\name{predict,xgb.Booster-method}
\alias{predict,xgb.Booster-method}
\title{Predict method for eXtreme Gradient Boosting model}
\usage{
\S4method{predict}{xgb.Booster}(object, newdata, outputmargin = FALSE,
ntreelimit = NULL)
}
\arguments{
\item{object}{Object of class "xgb.Boost"}
\item{newdata}{takes \code{matrix}, \code{dgCMatrix}, local data file or
\code{xgb.DMatrix}.}
\item{outputmargin}{whether the prediction should be shown in the original
value of sum of functions, when outputmargin=TRUE, the prediction is
untransformed margin value. In logistic regression, outputmargin=T will
output value before logistic transformation.}
\item{ntreelimit}{limit number of trees used in prediction, this parameter is
only valid for gbtree, but not for gblinear. set it to be value bigger
than 0. It will use all trees by default.}
}
\description{
Predicted values based on xgboost model object.
}
\examples{
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nround = 2,objective = "binary:logistic")
pred <- predict(bst, test$data)
}

View File

@@ -0,0 +1,129 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.Booster.R
\name{predict.xgb.Booster}
\alias{predict.xgb.Booster}
\alias{predict.xgb.Booster.handle}
\title{Predict method for eXtreme Gradient Boosting model}
\usage{
\method{predict}{xgb.Booster}(object, newdata, missing = NA,
outputmargin = FALSE, ntreelimit = NULL, predleaf = FALSE,
reshape = FALSE, ...)
\method{predict}{xgb.Booster.handle}(object, ...)
}
\arguments{
\item{object}{Object of class \code{xgb.Booster} or \code{xgb.Booster.handle}}
\item{newdata}{takes \code{matrix}, \code{dgCMatrix}, local data file or \code{xgb.DMatrix}.}
\item{missing}{Missing is only used when input is dense matrix. Pick a float value that represents
missing values in data (e.g., sometimes 0 or some other extreme value is used).}
\item{outputmargin}{whether the prediction should be returned in the for of original untransformed
sum of predictions from boosting iterations' results. E.g., setting \code{outputmargin=TRUE} for
logistic regression would result in predictions for log-odds instead of probabilities.}
\item{ntreelimit}{limit the number of model's trees or boosting iterations used in prediction (see Details).
It will use all the trees by default (\code{NULL} value).}
\item{predleaf}{whether predict leaf index instead.}
\item{reshape}{whether to reshape the vector of predictions to a matrix form when there are several
prediction outputs per case. This option has no effect when \code{predleaf = TRUE}.}
\item{...}{Parameters passed to \code{predict.xgb.Booster}}
}
\value{
For regression or binary classification, it returns a vector of length \code{nrows(newdata)}.
For multiclass classification, either a \code{num_class * nrows(newdata)} vector or
a \code{(nrows(newdata), num_class)} dimension matrix is returned, depending on
the \code{reshape} value.
When \code{predleaf = TRUE}, the output is a matrix object with the
number of columns corresponding to the number of trees.
}
\description{
Predicted values based on either xgboost model or model handle object.
}
\details{
Note that \code{ntreelimit} is not necesserily equal to the number of boosting iterations
and it is not necesserily equal to the number of trees in a model.
E.g., in a random forest-like model, \code{ntreelimit} would limit the number of trees.
But for multiclass classification, there are multiple trees per iteration,
but \code{ntreelimit} limits the number of boosting iterations.
Also note that \code{ntreelimit} would currently do nothing for predictions from gblinear,
since gblinear doesn't keep its boosting history.
One possible practical applications of the \code{predleaf} option is to use the model
as a generator of new features which capture non-linearity and interactions,
e.g., as implemented in \code{\link{xgb.create.features}}.
}
\examples{
## binary classification:
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
# use all trees by default
pred <- predict(bst, test$data)
# use only the 1st tree
pred <- predict(bst, test$data, ntreelimit = 1)
## multiclass classification in iris dataset:
lb <- as.numeric(iris$Species) - 1
num_class <- 3
set.seed(11)
bst <- xgboost(data = as.matrix(iris[, -5]), label = lb,
max_depth = 4, eta = 0.5, nthread = 2, nrounds = 10, subsample = 0.5,
objective = "multi:softprob", num_class = num_class)
# predict for softmax returns num_class probability numbers per case:
pred <- predict(bst, as.matrix(iris[, -5]))
str(pred)
# reshape it to a num_class-columns matrix
pred <- matrix(pred, ncol=num_class, byrow=TRUE)
# convert the probabilities to softmax labels
pred_labels <- max.col(pred) - 1
# the following should result in the same error as seen in the last iteration
sum(pred_labels != lb)/length(lb)
# compare that to the predictions from softmax:
set.seed(11)
bst <- xgboost(data = as.matrix(iris[, -5]), label = lb,
max_depth = 4, eta = 0.5, nthread = 2, nrounds = 10, subsample = 0.5,
objective = "multi:softmax", num_class = num_class)
pred <- predict(bst, as.matrix(iris[, -5]))
str(pred)
all.equal(pred, pred_labels)
# prediction from using only 5 iterations should result
# in the same error as seen in iteration 5:
pred5 <- predict(bst, as.matrix(iris[, -5]), ntreelimit=5)
sum(pred5 != lb)/length(lb)
## random forest-like model of 25 trees for binary classification:
set.seed(11)
bst <- xgboost(data = train$data, label = train$label, max_depth = 5,
nthread = 2, nrounds = 1, objective = "binary:logistic",
num_parallel_tree = 25, subsample = 0.6, colsample_bytree = 0.1)
# Inspect the prediction error vs number of trees:
lb <- test$label
dtest <- xgb.DMatrix(test$data, label=lb)
err <- sapply(1:25, function(n) {
pred <- predict(bst, dtest, ntreelimit=n)
sum((pred > 0.5) != lb)/length(lb)
})
plot(err, type='l', ylim=c(0,0.1), xlab='#trees')
}
\seealso{
\code{\link{xgb.train}}.
}

View File

@@ -0,0 +1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.Booster.R
\name{print.xgb.Booster}
\alias{print.xgb.Booster}
\title{Print xgb.Booster}
\usage{
\method{print}{xgb.Booster}(x, verbose = FALSE, ...)
}
\arguments{
\item{x}{an xgb.Booster object}
\item{verbose}{whether to print detailed data (e.g., attribute values)}
\item{...}{not currently used}
}
\description{
Print information about xgb.Booster.
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
attr(bst, 'myattr') <- 'memo'
print(bst)
print(bst, verbose=TRUE)
}

View File

@@ -0,0 +1,29 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.DMatrix.R
\name{print.xgb.DMatrix}
\alias{print.xgb.DMatrix}
\title{Print xgb.DMatrix}
\usage{
\method{print}{xgb.DMatrix}(x, verbose = FALSE, ...)
}
\arguments{
\item{x}{an xgb.DMatrix object}
\item{verbose}{whether to print colnames (when present)}
\item{...}{not currently used}
}
\description{
Print information about xgb.DMatrix.
Currently it displays dimensions and presence of info-fields and colnames.
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)
dtrain
print(dtrain, verbose=TRUE)
}

View File

@@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.cv.R
\name{print.xgb.cv.synchronous}
\alias{print.xgb.cv.synchronous}
\title{Print xgb.cv result}
\usage{
\method{print}{xgb.cv.synchronous}(x, verbose = FALSE, ...)
}
\arguments{
\item{x}{an \code{xgb.cv.synchronous} object}
\item{verbose}{whether to print detailed data}
\item{...}{passed to \code{data.table.print}}
}
\description{
Prints formatted results of \code{xgb.cv}.
}
\details{
When not verbose, it would only print the evaluation results,
including the best iteration (when available).
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
cv <- xgb.cv(data = train$data, label = train$label, nfold = 5, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
print(cv)
print(cv, verbose=TRUE)
}

View File

@@ -1,33 +1,44 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{methods}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.DMatrix.R
\name{setinfo}
\alias{setinfo}
\alias{setinfo,xgb.DMatrix-method}
\alias{setinfo.xgb.DMatrix}
\title{Set information of an xgb.DMatrix object}
\usage{
setinfo(object, ...)
\S4method{setinfo}{xgb.DMatrix}(object, name, info)
\method{setinfo}{xgb.DMatrix}(object, name, info, ...)
}
\arguments{
\item{object}{Object of class "xgb.DMatrix"}
\item{...}{other parameters}
\item{name}{the name of the field to get}
\item{info}{the specific field of information to set}
\item{...}{other parameters}
}
\description{
Set information of an xgb.DMatrix object
}
\details{
The \code{name} field can be one of the following:
\itemize{
\item \code{label}: label Xgboost learn from ;
\item \code{weight}: to do a weight rescale ;
\item \code{base_margin}: base margin is the base prediction Xgboost will boost from ;
\item \code{group}.
}
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)
labels <- getinfo(dtrain, 'label')
setinfo(dtrain, 'label', 1-labels)
labels2 <- getinfo(dtrain, 'label')
stopifnot(all(labels2 == 1-labels))
stopifnot(all.equal(labels2, 1-labels))
}

View File

@@ -1,30 +0,0 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{methods}
\name{slice}
\alias{slice}
\alias{slice,xgb.DMatrix-method}
\title{Get a new DMatrix containing the specified rows of
orginal xgb.DMatrix object}
\usage{
slice(object, ...)
\S4method{slice}{xgb.DMatrix}(object, idxset, ...)
}
\arguments{
\item{object}{Object of class "xgb.DMatrix"}
\item{idxset}{a integer vector of indices of rows needed}
\item{...}{other parameters}
}
\description{
Get a new DMatrix containing the specified rows of
orginal xgb.DMatrix object
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)
dsub <- slice(dtrain, 1:3)
}

View File

@@ -0,0 +1,41 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.DMatrix.R
\name{slice}
\alias{[.xgb.DMatrix}
\alias{slice}
\alias{slice.xgb.DMatrix}
\title{Get a new DMatrix containing the specified rows of
orginal xgb.DMatrix object}
\usage{
slice(object, ...)
\method{slice}{xgb.DMatrix}(object, idxset, ...)
\method{[}{xgb.DMatrix}(object, idxset, colset = NULL)
}
\arguments{
\item{object}{Object of class "xgb.DMatrix"}
\item{...}{other parameters (currently not used)}
\item{idxset}{a integer vector of indices of rows needed}
\item{colset}{currently not used (columns subsetting is not available)}
}
\description{
Get a new DMatrix containing the specified rows of
orginal xgb.DMatrix object
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)
dsub <- slice(dtrain, 1:42)
labels1 <- getinfo(dsub, 'label')
dsub <- dtrain[1:42, ]
labels2 <- getinfo(dsub, 'label')
all.equal(labels1, labels2)
}

View File

@@ -1,22 +1,24 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.DMatrix.R
\name{xgb.DMatrix}
\alias{xgb.DMatrix}
\title{Contruct xgb.DMatrix object}
\usage{
xgb.DMatrix(data, info = list(), missing = 0, ...)
xgb.DMatrix(data, info = list(), missing = NA, ...)
}
\arguments{
\item{data}{a \code{matrix} object, a \code{dgCMatrix} object or a character
indicating the data file.}
\item{data}{a \code{matrix} object, a \code{dgCMatrix} object or a character representing a filename}
\item{info}{a list of information of the xgb.DMatrix object}
\item{missing}{Missing is only used when input is dense matrix, pick a float}
\item{missing}{Missing is only used when input is dense matrix, pick a float
value that represents missing value. Sometime a data use 0 or other extreme value to represents missing values.}
\item{...}{other information to pass to \code{info}.}
}
\description{
Contruct xgb.DMatrix object from dense matrix, sparse matrix or local file.
Contruct xgb.DMatrix object from dense matrix, sparse matrix
or local file (that was created previously by saving an \code{xgb.DMatrix}).
}
\examples{
data(agaricus.train, package='xgboost')

View File

@@ -1,14 +1,15 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.DMatrix.save.R
\name{xgb.DMatrix.save}
\alias{xgb.DMatrix.save}
\title{Save xgb.DMatrix object to binary file}
\usage{
xgb.DMatrix.save(DMatrix, fname)
xgb.DMatrix.save(dmatrix, fname)
}
\arguments{
\item{DMatrix}{the DMatrix object}
\item{dmatrix}{the \code{xgb.DMatrix} object}
\item{fname}{the name of the binary file.}
\item{fname}{the name of the file to write.}
}
\description{
Save xgb.DMatrix object to binary file

86
R-package/man/xgb.attr.Rd Normal file
View File

@@ -0,0 +1,86 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.Booster.R
\name{xgb.attr}
\alias{xgb.attr}
\alias{xgb.attr<-}
\alias{xgb.attributes}
\alias{xgb.attributes<-}
\title{Accessors for serializable attributes of a model.}
\usage{
xgb.attr(object, name)
xgb.attr(object, name) <- value
xgb.attributes(object)
xgb.attributes(object) <- value
}
\arguments{
\item{object}{Object of class \code{xgb.Booster} or \code{xgb.Booster.handle}.}
\item{name}{a non-empty character string specifying which attribute is to be accessed.}
\item{value}{a value of an attribute for \code{xgb.attr<-}; for \code{xgb.attributes<-}
it's a list (or an object coercible to a list) with the names of attributes to set
and the elements corresponding to attribute values.
Non-character values are converted to character.
When attribute value is not a scalar, only the first index is used.
Use \code{NULL} to remove an attribute.}
}
\value{
\code{xgb.attr} returns either a string value of an attribute
or \code{NULL} if an attribute wasn't stored in a model.
\code{xgb.attributes} returns a list of all attribute stored in a model
or \code{NULL} if a model has no stored attributes.
}
\description{
These methods allow to manipulate the key-value attribute strings of an xgboost model.
}
\details{
The primary purpose of xgboost model attributes is to store some meta-data about the model.
Note that they are a separate concept from the object attributes in R.
Specifically, they refer to key-value strings that can be attached to an xgboost model,
stored together with the model's binary representation, and accessed later
(from R or any other interface).
In contrast, any R-attribute assigned to an R-object of \code{xgb.Booster} class
would not be saved by \code{xgb.save} because an xgboost model is an external memory object
and its serialization is handled extrnally.
Also, setting an attribute that has the same name as one of xgboost's parameters wouldn't
change the value of that parameter for a model.
Use \code{\link{xgb.parameters<-}} to set or change model parameters.
The attribute setters would usually work more efficiently for \code{xgb.Booster.handle}
than for \code{xgb.Booster}, since only just a handle (pointer) would need to be copied.
That would only matter if attributes need to be set many times.
Note, however, that when feeding a handle of an \code{xgb.Booster} object to the attribute setters,
the raw model cache of an \code{xgb.Booster} object would not be automatically updated,
and it would be user's responsibility to call \code{xgb.save.raw} to update it.
The \code{xgb.attributes<-} setter either updates the existing or adds one or several attributes,
but it doesn't delete the other existing attributes.
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
xgb.attr(bst, "my_attribute") <- "my attribute value"
print(xgb.attr(bst, "my_attribute"))
xgb.attributes(bst) <- list(a = 123, b = "abc")
xgb.save(bst, 'xgb.model')
bst1 <- xgb.load('xgb.model')
print(xgb.attr(bst1, "my_attribute"))
print(xgb.attributes(bst1))
# deletion:
xgb.attr(bst1, "my_attribute") <- NULL
print(xgb.attributes(bst1))
xgb.attributes(bst1) <- list(a = NULL, b = NULL)
print(xgb.attributes(bst1))
}

View File

@@ -0,0 +1,90 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.create.features.R
\name{xgb.create.features}
\alias{xgb.create.features}
\title{Create new features from a previously learned model}
\usage{
xgb.create.features(model, data, ...)
}
\arguments{
\item{model}{decision tree boosting model learned on the original data}
\item{data}{original data (usually provided as a \code{dgCMatrix} matrix)}
\item{...}{currently not used}
}
\value{
\code{dgCMatrix} matrix including both the original data and the new features.
}
\description{
May improve the learning by adding new features to the training data based on the decision trees from a previously learned model.
}
\details{
This is the function inspired from the paragraph 3.1 of the paper:
\strong{Practical Lessons from Predicting Clicks on Ads at Facebook}
\emph{(Xinran He, Junfeng Pan, Ou Jin, Tianbing Xu, Bo Liu, Tao Xu, Yan, xin Shi, Antoine Atallah, Ralf Herbrich, Stuart Bowers,
Joaquin Quinonero Candela)}
International Workshop on Data Mining for Online Advertising (ADKDD) - August 24, 2014
\url{https://research.facebook.com/publications/758569837499391/practical-lessons-from-predicting-clicks-on-ads-at-facebook/}.
Extract explaining the method:
"We found that boosted decision trees are a powerful and very
convenient way to implement non-linear and tuple transformations
of the kind we just described. We treat each individual
tree as a categorical feature that takes as value the
index of the leaf an instance ends up falling in. We use
1-of-K coding of this type of features.
For example, consider the boosted tree model in Figure 1 with 2 subtrees,
where the first subtree has 3 leafs and the second 2 leafs. If an
instance ends up in leaf 2 in the first subtree and leaf 1 in
second subtree, the overall input to the linear classifier will
be the binary vector \code{[0, 1, 0, 1, 0]}, where the first 3 entries
correspond to the leaves of the first subtree and last 2 to
those of the second subtree.
[...]
We can understand boosted decision tree
based transformation as a supervised feature encoding that
converts a real-valued vector into a compact binary-valued
vector. A traversal from root node to a leaf node represents
a rule on certain features."
}
\examples{
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
dtrain <- xgb.DMatrix(data = agaricus.train$data, label = agaricus.train$label)
dtest <- xgb.DMatrix(data = agaricus.test$data, label = agaricus.test$label)
param <- list(max_depth=2, eta=1, silent=1, objective='binary:logistic')
nround = 4
bst = xgb.train(params = param, data = dtrain, nrounds = nround, nthread = 2)
# Model accuracy without new features
accuracy.before <- sum((predict(bst, agaricus.test$data) >= 0.5) == agaricus.test$label) / length(agaricus.test$label)
# Convert previous features to one hot encoding
new.features.train <- xgb.create.features(model = bst, agaricus.train$data)
new.features.test <- xgb.create.features(model = bst, agaricus.test$data)
# learning with new features
new.dtrain <- xgb.DMatrix(data = new.features.train, label = agaricus.train$label)
new.dtest <- xgb.DMatrix(data = new.features.test, label = agaricus.test$label)
watchlist <- list(train = new.dtrain)
bst <- xgb.train(params = param, data = new.dtrain, nrounds = nround, nthread = 2)
# Model accuracy with new features
accuracy.after <- sum((predict(bst, new.dtest) >= 0.5) == agaricus.test$label) / length(agaricus.test$label)
# Here the accuracy was already good and is now perfect.
cat(paste("The accuracy was", accuracy.before, "before adding leaf features and it is now", accuracy.after, "!\\n"))
}

View File

@@ -1,10 +1,14 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.cv.R
\name{xgb.cv}
\alias{xgb.cv}
\title{Cross Validation}
\usage{
xgb.cv(params = list(), data, nrounds, nfold, label = NULL, showsd = TRUE,
metrics = list(), obj = NULL, feval = NULL, ...)
xgb.cv(params = list(), data, nrounds, nfold, label = NULL, missing = NA,
prediction = FALSE, showsd = TRUE, metrics = list(), obj = NULL,
feval = NULL, stratified = TRUE, folds = NULL, verbose = TRUE,
print_every_n = 1L, early_stopping_rounds = NULL, maximize = NULL,
callbacks = list(), ...)
}
\arguments{
\item{params}{the list of parameters. Commonly used ones are:
@@ -15,24 +19,31 @@ xgb.cv(params = list(), data, nrounds, nfold, label = NULL, showsd = TRUE,
\item \code{binary:logistic} logistic regression for classification
}
\item \code{eta} step size of each boosting step
\item \code{max.depth} maximum depth of the tree
\item \code{max_depth} maximum depth of the tree
\item \code{nthread} number of thread used in training, if not set, all threads are used
}
See \url{https://github.com/tqchen/xgboost/wiki/Parameters} for
further details. See also demo/ for walkthrough example in R.}
See \code{\link{xgb.train}} for further details.
See also demo/ for walkthrough example in R.}
\item{data}{takes an \code{xgb.DMatrix} as the input.}
\item{data}{takes an \code{xgb.DMatrix} or \code{Matrix} as the input.}
\item{nrounds}{the max number of iterations}
\item{nfold}{number of folds used}
\item{nfold}{the original dataset is randomly partitioned into \code{nfold} equal size subsamples.}
\item{label}{option field, when data is Matrix}
\item{label}{vector of response values. Should be provided only when data is \code{DMatrix}.}
\item{showsd}{boolean, whether show standard deviation of cross validation}
\item{missing}{is only used when input is a dense matrix. By default is set to NA, which means
that NA values should be considered as 'missing' by the algorithm.
Sometimes, 0 or other extreme value might be used to represent missing values.}
\item{metrics,}{list of evaluation metrics to be used in corss validation,
\item{prediction}{A logical value indicating whether to return the test fold predictions
from each CV model. This parameter engages the \code{\link{cb.cv.predict}} callback.}
\item{showsd}{\code{boolean}, whether to show standard deviation of cross validation}
\item{metrics, }{list of evaluation metrics to be used in cross validation,
when it is not specified, the evaluation metric is chosen according to objective function.
Possible options are:
\itemize{
@@ -43,30 +54,90 @@ xgb.cv(params = list(), data, nrounds, nfold, label = NULL, showsd = TRUE,
\item \code{merror} Exact matching error, used to evaluate multi-class classification
}}
\item{obj}{customized objective function. Returns gradient and second order
gradient with given prediction and dtrain,}
\item{obj}{customized objective function. Returns gradient and second order
gradient with given prediction and dtrain.}
\item{feval}{custimized evaluation function. Returns
\code{list(metric='metric-name', value='metric-value')} with given
prediction and dtrain,}
\item{feval}{custimized evaluation function. Returns
\code{list(metric='metric-name', value='metric-value')} with given
prediction and dtrain.}
\item{stratified}{a \code{boolean} indicating whether sampling of folds should be stratified
by the values of outcome labels.}
\item{folds}{\code{list} provides a possibility to use a list of pre-defined CV folds
(each element must be a vector of test fold's indices). When folds are supplied,
the \code{nfold} and \code{stratified} parameters are ignored.}
\item{verbose}{\code{boolean}, print the statistics during the process}
\item{print_every_n}{Print each n-th iteration evaluation messages when \code{verbose>0}.
Default is 1 which means all messages are printed. This parameter is passed to the
\code{\link{cb.print.evaluation}} callback.}
\item{early_stopping_rounds}{If \code{NULL}, the early stopping function is not triggered.
If set to an integer \code{k}, training with a validation set will stop if the performance
doesn't improve for \code{k} rounds.
Setting this parameter engages the \code{\link{cb.early.stop}} callback.}
\item{maximize}{If \code{feval} and \code{early_stopping_rounds} are set,
then this parameter must be set as well.
When it is \code{TRUE}, it means the larger the evaluation score the better.
This parameter is passed to the \code{\link{cb.early.stop}} callback.}
\item{callbacks}{a list of callback functions to perform various task during boosting.
See \code{\link{callbacks}}. Some of the callbacks are automatically created depending on the
parameters' values. User can provide either existing or their own callback methods in order
to customize the training process.}
\item{...}{other parameters to pass to \code{params}.}
}
\value{
An object of class \code{xgb.cv.synchronous} with the following elements:
\itemize{
\item \code{call} a function call.
\item \code{params} parameters that were passed to the xgboost library. Note that it does not
capture parameters changed by the \code{\link{cb.reset.parameters}} callback.
\item \code{callbacks} callback functions that were either automatically assigned or
explicitely passed.
\item \code{evaluation_log} evaluation history storead as a \code{data.table} with the
first column corresponding to iteration number and the rest corresponding to the
CV-based evaluation means and standard deviations for the training and test CV-sets.
It is created by the \code{\link{cb.evaluation.log}} callback.
\item \code{niter} number of boosting iterations.
\item \code{folds} the list of CV folds' indices - either those passed through the \code{folds}
parameter or randomly generated.
\item \code{best_iteration} iteration number with the best evaluation metric value
(only available with early stopping).
\item \code{best_ntreelimit} the \code{ntreelimit} value corresponding to the best iteration,
which could further be used in \code{predict} method
(only available with early stopping).
\item \code{pred} CV prediction values available when \code{prediction} is set.
It is either vector or matrix (see \code{\link{cb.cv.predict}}).
\item \code{models} a liost of the CV folds' models. It is only available with the explicit
setting of the \code{cb.cv.predict(save_models = TRUE)} callback.
}
}
\description{
The cross valudation function of xgboost
}
\details{
This is the cross validation function for xgboost
The original sample is randomly partitioned into \code{nfold} equal size subsamples.
Parallelization is automatically enabled if OpenMP is present.
Number of threads can also be manually specified via "nthread" parameter.
Of the \code{nfold} subsamples, a single subsample is retained as the validation data for testing the model, and the remaining \code{nfold - 1} subsamples are used as training data.
This function only accepts an \code{xgb.DMatrix} object as the input.
The cross-validation process is then repeated \code{nrounds} times, with each of the \code{nfold} subsamples used exactly once as the validation data.
All observations are used for both training and validation.
Adapted from \url{http://en.wikipedia.org/wiki/Cross-validation_\%28statistics\%29#k-fold_cross-validation}
}
\examples{
data(agaricus.train, package='xgboost')
dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)
history <- xgb.cv(data = dtrain, nround=3, nfold = 5, metrics=list("rmse","auc"),
"max.depth"=3, "eta"=1, "objective"="binary:logistic")
cv <- xgb.cv(data = dtrain, nrounds = 3, nthread = 2, nfold = 5, metrics = list("rmse","auc"),
max_depth = 3, eta = 1, objective = "binary:logistic")
print(cv)
print(cv, verbose=TRUE)
}

View File

@@ -1,21 +1,32 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.dump.R
\name{xgb.dump}
\alias{xgb.dump}
\title{Save xgboost model to text file}
\usage{
xgb.dump(model, fname, fmap = "")
xgb.dump(model = NULL, fname = NULL, fmap = "", with_stats = FALSE, ...)
}
\arguments{
\item{model}{the model object.}
\item{fname}{the name of the binary file.}
\item{fname}{the name of the text file where to save the model text dump. If not provided or set to \code{NULL} the function will return the model as a \code{character} vector.}
\item{fmap}{feature map file representing the type of feature.
Detailed description could be found at
\url{https://github.com/tqchen/xgboost/wiki/Binary-Classification#dump-model}.
See demo/ for walkthrough example in R, and
\url{https://github.com/tqchen/xgboost/blob/master/demo/data/featmap.txt}
for example Format.}
\item{fmap}{feature map file representing the type of feature.
Detailed description could be found at
\url{https://github.com/dmlc/xgboost/wiki/Binary-Classification#dump-model}.
See demo/ for walkthrough example in R, and
\url{https://github.com/dmlc/xgboost/blob/master/demo/data/featmap.txt}
for example Format.}
\item{with_stats}{whether dump statistics of splits
When this option is on, the model dump comes with two additional statistics:
gain is the approximate loss function gain we get in each split;
cover is the sum of second order gradient in each node.}
\item{...}{currently not used}
}
\value{
if fname is not provided or set to \code{NULL} the function will return the model as a \code{character} vector. Otherwise it will return \code{TRUE}.
}
\description{
Save a xgboost model to text file. Could be parsed later.
@@ -25,8 +36,12 @@ data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nround = 2,objective = "binary:logistic")
xgb.dump(bst, 'xgb.model.dump')
bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
# save the model in file 'xgb.model.dump'
xgb.dump(bst, 'xgb.model.dump', with_stats = TRUE)
# print the model without saving it to a file
print(xgb.dump(bst))
}

View File

@@ -0,0 +1,64 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.importance.R
\name{xgb.importance}
\alias{xgb.importance}
\title{Show importance of features in a model}
\usage{
xgb.importance(feature_names = NULL, model = NULL, data = NULL,
label = NULL, target = function(x) ((x + label) == 2))
}
\arguments{
\item{feature_names}{names of each feature as a \code{character} vector. Can be extracted from a sparse matrix (see example). If model dump already contains feature names, this argument should be \code{NULL}.}
\item{model}{generated by the \code{xgb.train} function.}
\item{data}{the dataset used for the training step. Will be used with \code{label} parameter for co-occurence computation. More information in \code{Detail} part. This parameter is optional.}
\item{label}{the label vetor used for the training step. Will be used with \code{data} parameter for co-occurence computation. More information in \code{Detail} part. This parameter is optional.}
\item{target}{a function which returns \code{TRUE} or \code{1} when an observation should be count as a co-occurence and \code{FALSE} or \code{0} otherwise. Default function is provided for computing co-occurences in a binary classification. The \code{target} function should have only one parameter. This parameter will be used to provide each important feature vector after having applied the split condition, therefore these vector will be only made of 0 and 1 only, whatever was the information before. More information in \code{Detail} part. This parameter is optional.}
}
\value{
A \code{data.table} of the features used in the model with their average gain (and their weight for boosted tree model) in the model.
}
\description{
Create a \code{data.table} of the most important features of a model.
}
\details{
This function is for both linear and tree models.
\code{data.table} is returned by the function.
The columns are :
\itemize{
\item \code{Features} name of the features as provided in \code{feature_names} or already present in the model dump;
\item \code{Gain} contribution of each feature to the model. For boosted tree model, each gain of each feature of each tree is taken into account, then average per feature to give a vision of the entire model. Highest percentage means important feature to predict the \code{label} used for the training (only available for tree models);
\item \code{Cover} metric of the number of observation related to this feature (only available for tree models);
\item \code{Weight} percentage representing the relative number of times a feature have been taken into trees.
}
If you don't provide \code{feature_names}, index of the features will be used instead.
Because the index is extracted from the model dump (made on the C++ side), it starts at 0 (usual in C++) instead of 1 (usual in R).
Co-occurence count
------------------
The gain gives you indication about the information of how a feature is important in making a branch of a decision tree more pure. However, with this information only, you can't know if this feature has to be present or not to get a specific classification. In the example code, you may wonder if odor=none should be \code{TRUE} to not eat a mushroom.
Co-occurence computation is here to help in understanding this relation between a predictor and a specific class. It will count how many observations are returned as \code{TRUE} by the \code{target} function (see parameters). When you execute the example below, there are 92 times only over the 3140 observations of the train dataset where a mushroom have no odor and can be eaten safely.
If you need to remember one thing only: until you want to leave us early, don't eat a mushroom which has no odor :-)
}
\examples{
data(agaricus.train, package='xgboost')
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
xgb.importance(colnames(agaricus.train$data), model = bst)
# Same thing with co-occurence computation this time
xgb.importance(colnames(agaricus.train$data), model = bst, data = agaricus.train$data, label = agaricus.train$label)
}

View File

@@ -1,4 +1,5 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.load.R
\name{xgb.load}
\alias{xgb.load}
\title{Load xgboost model from binary file}
@@ -16,8 +17,8 @@ data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nround = 2,objective = "binary:logistic")
bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
xgb.save(bst, 'xgb.model')
bst <- xgb.load('xgb.model')
pred <- predict(bst, test$data)

View File

@@ -0,0 +1,61 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.model.dt.tree.R
\name{xgb.model.dt.tree}
\alias{xgb.model.dt.tree}
\title{Parse a boosted tree model text dump}
\usage{
xgb.model.dt.tree(feature_names = NULL, model = NULL, text = NULL,
n_first_tree = NULL)
}
\arguments{
\item{feature_names}{character vector of feature names. If the model already
contains feature names, this argument should be \code{NULL} (default value)}
\item{model}{object of class \code{xgb.Booster}}
\item{text}{\code{character} vector previously generated by the \code{xgb.dump}
function (where parameter \code{with_stats = TRUE} should have been set).}
\item{n_first_tree}{limit the parsing to the \code{n} first trees.
If set to \code{NULL}, all trees of the model are parsed.}
}
\value{
A \code{data.table} with detailed information about model trees' nodes.
The columns of the \code{data.table} are:
\itemize{
\item \code{Tree}: ID of a tree in a model
\item \code{Node}: ID of a node in a tree
\item \code{ID}: unique identifier of a node in a model
\item \code{Feature}: for a branch node, it's a feature id or name (when available);
for a leaf note, it simply labels it as \code{'Leaf'}
\item \code{Split}: location of the split for a branch node (split condition is always "less than")
\item \code{Yes}: ID of the next node when the split condition is met
\item \code{No}: ID of the next node when the split condition is not met
\item \code{Missing}: ID of the next node when branch value is missing
\item \code{Quality}: either the split gain (change in loss) or the leaf value
\item \code{Cover}: metric related to the number of observation either seen by a split
or collected by a leaf during training.
}
}
\description{
Parse a boosted tree model text dump into a \code{data.table} structure.
}
\examples{
# Basic use:
data(agaricus.train, package='xgboost')
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
(dt <- xgb.model.dt.tree(colnames(agaricus.train$data), bst))
# How to match feature names of splits that are following a current 'Yes' branch:
merge(dt, dt[, .(ID, Y.Feature=Feature)], by.x='Yes', by.y='ID', all.x=TRUE)[order(Tree,Node)]
}

View File

@@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.Booster.R
\name{xgb.parameters<-}
\alias{xgb.parameters<-}
\title{Accessors for model parameters.}
\usage{
xgb.parameters(object) <- value
}
\arguments{
\item{object}{Object of class \code{xgb.Booster} or \code{xgb.Booster.handle}.}
\item{value}{a list (or an object coercible to a list) with the names of parameters to set
and the elements corresponding to parameter values.}
}
\description{
Only the setter for xgboost parameters is currently implemented.
}
\details{
Note that the setter would usually work more efficiently for \code{xgb.Booster.handle}
than for \code{xgb.Booster}, since only just a handle would need to be copied.
}
\examples{
data(agaricus.train, package='xgboost')
train <- agaricus.train
bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
xgb.parameters(bst) <- list(eta = 0.1)
}

View File

@@ -0,0 +1,74 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.ggplot.R, R/xgb.plot.deepness.R
\name{xgb.ggplot.deepness}
\alias{xgb.ggplot.deepness}
\alias{xgb.plot.deepness}
\title{Plot model trees deepness}
\usage{
xgb.ggplot.deepness(model = NULL, which = c("2x1", "max.depth", "med.depth",
"med.weight"))
xgb.plot.deepness(model = NULL, which = c("2x1", "max.depth", "med.depth",
"med.weight"), plot = TRUE, ...)
}
\arguments{
\item{model}{either an \code{xgb.Booster} model generated by the \code{xgb.train} function
or a data.table result of the \code{xgb.model.dt.tree} function.}
\item{which}{which distribution to plot (see details).}
\item{plot}{(base R barplot) whether a barplot should be produced.
If FALSE, only a data.table is returned.}
\item{...}{other parameters passed to \code{barplot} or \code{plot}.}
}
\value{
Other than producing plots (when \code{plot=TRUE}), the \code{xgb.plot.deepness} function
silently returns a processed data.table where each row corresponds to a terminal leaf in a tree model,
and contains information about leaf's depth, cover, and weight (which is used in calculating predictions).
The \code{xgb.ggplot.deepness} silently returns either a list of two ggplot graphs when \code{which="2x1"}
or a single ggplot graph for the other \code{which} options.
}
\description{
Visualizes distributions related to depth of tree leafs.
\code{xgb.plot.deepness} uses base R graphics, while \code{xgb.ggplot.deepness} uses the ggplot backend.
}
\details{
When \code{which="2x1"}, two distributions with respect to the leaf depth
are plotted on top of each other:
\itemize{
\item the distribution of the number of leafs in a tree model at a certain depth;
\item the distribution of average weighted number of observations ("cover")
ending up in leafs at certain depth.
}
Those could be helpful in determining sensible ranges of the \code{max_depth}
and \code{min_child_weight} parameters.
When \code{which="max.depth"} or \code{which="med.depth"}, plots of either maximum or median depth
per tree with respect to tree number are created. And \code{which="med.weight"} allows to see how
a tree's median absolute leaf weight changes through the iterations.
This function was inspired by the blog post
\url{http://aysent.github.io/2015/11/08/random-forest-leaf-visualization.html}.
}
\examples{
data(agaricus.train, package='xgboost')
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 15,
eta = 0.1, nthread = 2, nrounds = 50, objective = "binary:logistic",
subsample = 0.5, min_child_weight = 2)
xgb.plot.deepness(bst)
xgb.ggplot.deepness(bst)
xgb.plot.deepness(bst, which='max.depth', pch=16, col=rgb(0,0,1,0.3), cex=2)
xgb.plot.deepness(bst, which='med.weight', pch=16, col=rgb(0,0,1,0.3), cex=2)
}
\seealso{
\code{\link{xgb.train}}, \code{\link{xgb.model.dt.tree}}.
}

View File

@@ -0,0 +1,82 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.ggplot.R, R/xgb.plot.importance.R
\name{xgb.ggplot.importance}
\alias{xgb.ggplot.importance}
\alias{xgb.plot.importance}
\title{Plot feature importance as a bar graph}
\usage{
xgb.ggplot.importance(importance_matrix = NULL, top_n = NULL,
measure = NULL, rel_to_first = FALSE, n_clusters = c(1:10), ...)
xgb.plot.importance(importance_matrix = NULL, top_n = NULL,
measure = NULL, rel_to_first = FALSE, left_margin = 10, cex = NULL,
plot = TRUE, ...)
}
\arguments{
\item{importance_matrix}{a \code{data.table} returned by \code{\link{xgb.importance}}.}
\item{top_n}{maximal number of top features to include into the plot.}
\item{measure}{the name of importance measure to plot.
When \code{NULL}, 'Gain' would be used for trees and 'Weight' would be used for gblinear.}
\item{rel_to_first}{whether importance values should be represented as relative to the highest ranked feature.
See Details.}
\item{n_clusters}{(ggplot only) a \code{numeric} vector containing the min and the max range
of the possible number of clusters of bars.}
\item{...}{other parameters passed to \code{barplot} (except horiz, border, cex.names, names.arg, and las).}
\item{left_margin}{(base R barplot) allows to adjust the left margin size to fit feature names.
When it is NULL, the existing \code{par('mar')} is used.}
\item{cex}{(base R barplot) passed as \code{cex.names} parameter to \code{barplot}.}
\item{plot}{(base R barplot) whether a barplot should be produced.
If FALSE, only a data.table is returned.}
}
\value{
The \code{xgb.plot.importance} function creates a \code{barplot} (when \code{plot=TRUE})
and silently returns a processed data.table with \code{n_top} features sorted by importance.
The \code{xgb.ggplot.importance} function returns a ggplot graph which could be customized afterwards.
E.g., to change the title of the graph, add \code{+ ggtitle("A GRAPH NAME")} to the result.
}
\description{
Represents previously calculated feature importance as a bar graph.
\code{xgb.plot.importance} uses base R graphics, while \code{xgb.ggplot.importance} uses the ggplot backend.
}
\details{
The graph represents each feature as a horizontal bar of length proportional to the importance of a feature.
Features are shown ranked in a decreasing importance order.
It works for importances from both \code{gblinear} and \code{gbtree} models.
When \code{rel_to_first = FALSE}, the values would be plotted as they were in \code{importance_matrix}.
For gbtree model, that would mean being normalized to the total of 1
("what is feature's importance contribution relative to the whole model?").
For linear models, \code{rel_to_first = FALSE} would show actual values of the coefficients.
Setting \code{rel_to_first = TRUE} allows to see the picture from the perspective of
"what is feature's importance contribution relative to the most important feature?"
The ggplot-backend method also performs 1-D custering of the importance values,
with bar colors coresponding to different clusters that have somewhat similar importance values.
}
\examples{
data(agaricus.train)
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 3,
eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
importance_matrix <- xgb.importance(colnames(agaricus.train$data), model = bst)
xgb.plot.importance(importance_matrix, rel_to_first = TRUE, xlab = "Relative importance")
(gg <- xgb.ggplot.importance(importance_matrix, measure = "Frequency", rel_to_first = TRUE))
gg + ggplot2::ylab("Frequency")
}
\seealso{
\code{\link[graphics]{barplot}}.
}

View File

@@ -0,0 +1,60 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.plot.multi.trees.R
\name{xgb.plot.multi.trees}
\alias{xgb.plot.multi.trees}
\title{Project all trees on one tree and plot it}
\usage{
xgb.plot.multi.trees(model, feature_names = NULL, features_keep = 5,
plot_width = NULL, plot_height = NULL, ...)
}
\arguments{
\item{model}{dump generated by the \code{xgb.train} function.}
\item{feature_names}{names of each feature as a \code{character} vector. Can be extracted from a sparse matrix (see example). If model dump already contains feature names, this argument should be \code{NULL}.}
\item{features_keep}{number of features to keep in each position of the multi trees.}
\item{plot_width}{width in pixels of the graph to produce}
\item{plot_height}{height in pixels of the graph to produce}
\item{...}{currently not used}
}
\value{
Two graphs showing the distribution of the model deepness.
}
\description{
Visualization of the ensemble of trees as a single collective unit.
}
\details{
This function tries to capture the complexity of gradient boosted tree ensemble
in a cohesive way.
The goal is to improve the interpretability of the model generally seen as black box.
The function is dedicated to boosting applied to decision trees only.
The purpose is to move from an ensemble of trees to a single tree only.
It takes advantage of the fact that the shape of a binary tree is only defined by
its deepness (therefore in a boosting model, all trees have the same shape).
Moreover, the trees tend to reuse the same features.
The function will project each tree on one, and keep for each position the
\code{features_keep} first features (based on Gain per feature measure).
This function is inspired by this blog post:
\url{https://wellecks.wordpress.com/2015/02/21/peering-into-the-black-box-visualizing-lambdamart/}
}
\examples{
data(agaricus.train, package='xgboost')
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 15,
eta = 1, nthread = 2, nrounds = 30, objective = "binary:logistic",
min_child_weight = 50)
p <- xgb.plot.multi.trees(model = bst, feature_names = colnames(agaricus.train$data), features_keep = 3)
print(p)
}

View File

@@ -0,0 +1,49 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.plot.tree.R
\name{xgb.plot.tree}
\alias{xgb.plot.tree}
\title{Plot a boosted tree model}
\usage{
xgb.plot.tree(feature_names = NULL, model = NULL, n_first_tree = NULL,
plot_width = NULL, plot_height = NULL, ...)
}
\arguments{
\item{feature_names}{names of each feature as a \code{character} vector. Can be extracted from a sparse matrix (see example). If model dump already contains feature names, this argument should be \code{NULL}.}
\item{model}{generated by the \code{xgb.train} function. Avoid the creation of a dump file.}
\item{n_first_tree}{limit the plot to the n first trees. If \code{NULL}, all trees of the model are plotted. Performance can be low for huge models.}
\item{plot_width}{the width of the diagram in pixels.}
\item{plot_height}{the height of the diagram in pixels.}
\item{...}{currently not used.}
}
\value{
A \code{DiagrammeR} of the model.
}
\description{
Read a tree model text dump and plot the model.
}
\details{
The content of each node is organised that way:
\itemize{
\item \code{feature} value;
\item \code{cover}: the sum of second order gradient of training data classified to the leaf, if it is square loss, this simply corresponds to the number of instances in that branch. Deeper in the tree a node is, lower this metric will be;
\item \code{gain}: metric the importance of the node in the model.
}
The function uses \href{http://www.graphviz.org/}{GraphViz} library for that purpose.
}
\examples{
data(agaricus.train, package='xgboost')
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
xgb.plot.tree(feature_names = colnames(agaricus.train$data), model = bst)
}

View File

@@ -1,4 +1,5 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.save.R
\name{xgb.save}
\alias{xgb.save}
\title{Save xgboost model to binary file}
@@ -8,7 +9,7 @@ xgb.save(model, fname)
\arguments{
\item{model}{the model object.}
\item{fname}{the name of the binary file.}
\item{fname}{the name of the file to write.}
}
\description{
Save xgboost model from xgboost or xgb.train
@@ -18,8 +19,8 @@ data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nround = 2,objective = "binary:logistic")
bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
xgb.save(bst, 'xgb.model')
bst <- xgb.load('xgb.model')
pred <- predict(bst, test$data)

View File

@@ -0,0 +1,28 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.save.raw.R
\name{xgb.save.raw}
\alias{xgb.save.raw}
\title{Save xgboost model to R's raw vector,
user can call xgb.load to load the model back from raw vector}
\usage{
xgb.save.raw(model)
}
\arguments{
\item{model}{the model object.}
}
\description{
Save xgboost model from xgboost or xgb.train
}
\examples{
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
raw <- xgb.save.raw(bst)
bst <- xgb.load(raw)
pred <- predict(bst, test$data)
}

View File

@@ -1,68 +1,210 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xgb.train.R, R/xgboost.R
\name{xgb.train}
\alias{xgb.train}
\alias{xgboost}
\title{eXtreme Gradient Boosting Training}
\usage{
xgb.train(params = list(), data, nrounds, watchlist = list(), obj = NULL,
feval = NULL, verbose = 1, ...)
feval = NULL, verbose = 1, print_every_n = 1L,
early_stopping_rounds = NULL, maximize = NULL, save_period = NULL,
save_name = "xgboost.model", xgb_model = NULL, callbacks = list(), ...)
xgboost(data = NULL, label = NULL, missing = NA, weight = NULL,
params = list(), nrounds, verbose = 1, print_every_n = 1L,
early_stopping_rounds = NULL, maximize = NULL, save_period = 0,
save_name = "xgboost.model", xgb_model = NULL, callbacks = list(), ...)
}
\arguments{
\item{params}{the list of parameters. Commonly used ones are:
\item{params}{the list of parameters.
The complete list of parameters is available at \url{http://xgboost.readthedocs.io/en/latest/parameter.html}.
Below is a shorter summary:
1. General Parameters
\itemize{
\item \code{objective} objective function, common ones are
\itemize{
\item \code{reg:linear} linear regression
\item \code{binary:logistic} logistic regression for classification
}
\item \code{eta} step size of each boosting step
\item \code{max.depth} maximum depth of the tree
\item \code{nthread} number of thread used in training, if not set, all threads are used
\item \code{booster} which booster to use, can be \code{gbtree} or \code{gblinear}. Default: \code{gbtree}
\item \code{silent} 0 means printing running messages, 1 means silent mode. Default: 0
}
2. Booster Parameters
2.1. Parameter for Tree Booster
\itemize{
\item \code{eta} control the learning rate: scale the contribution of each tree by a factor of \code{0 < eta < 1} when it is added to the current approximation. Used to prevent overfitting by making the boosting process more conservative. Lower value for \code{eta} implies larger value for \code{nrounds}: low \code{eta} value means model more robust to overfitting but slower to compute. Default: 0.3
\item \code{gamma} minimum loss reduction required to make a further partition on a leaf node of the tree. the larger, the more conservative the algorithm will be.
\item \code{max_depth} maximum depth of a tree. Default: 6
\item \code{min_child_weight} minimum sum of instance weight (hessian) needed in a child. If the tree partition step results in a leaf node with the sum of instance weight less than min_child_weight, then the building process will give up further partitioning. In linear regression mode, this simply corresponds to minimum number of instances needed to be in each node. The larger, the more conservative the algorithm will be. Default: 1
\item \code{subsample} subsample ratio of the training instance. Setting it to 0.5 means that xgboost randomly collected half of the data instances to grow trees and this will prevent overfitting. It makes computation shorter (because less data to analyse). It is advised to use this parameter with \code{eta} and increase \code{nround}. Default: 1
\item \code{colsample_bytree} subsample ratio of columns when constructing each tree. Default: 1
\item \code{num_parallel_tree} Experimental parameter. number of trees to grow per round. Useful to test Random Forest through Xgboost (set \code{colsample_bytree < 1}, \code{subsample < 1} and \code{round = 1}) accordingly. Default: 1
}
See \url{https://github.com/tqchen/xgboost/wiki/Parameters} for
further details. See also demo/ for walkthrough example in R.}
2.2. Parameter for Linear Booster
\itemize{
\item \code{lambda} L2 regularization term on weights. Default: 0
\item \code{lambda_bias} L2 regularization term on bias. Default: 0
\item \code{alpha} L1 regularization term on weights. (there is no L1 reg on bias because it is not important). Default: 0
}
\item{data}{takes an \code{xgb.DMatrix} as the input.}
3. Task Parameters
\itemize{
\item \code{objective} specify the learning task and the corresponding learning objective, users can pass a self-defined function to it. The default objective options are below:
\itemize{
\item \code{reg:linear} linear regression (Default).
\item \code{reg:logistic} logistic regression.
\item \code{binary:logistic} logistic regression for binary classification. Output probability.
\item \code{binary:logitraw} logistic regression for binary classification, output score before logistic transformation.
\item \code{num_class} set the number of classes. To use only with multiclass objectives.
\item \code{multi:softmax} set xgboost to do multiclass classification using the softmax objective. Class is represented by a number and should be from 0 to \code{num_class - 1}.
\item \code{multi:softprob} same as softmax, but prediction outputs a vector of ndata * nclass elements, which can be further reshaped to ndata, nclass matrix. The result contains predicted probabilities of each data point belonging to each class.
\item \code{rank:pairwise} set xgboost to do ranking task by minimizing the pairwise loss.
}
\item \code{base_score} the initial prediction score of all instances, global bias. Default: 0.5
\item \code{eval_metric} evaluation metrics for validation data. Users can pass a self-defined function to it. Default: metric will be assigned according to objective(rmse for regression, and error for classification, mean average precision for ranking). List is provided in detail section.
}}
\item{data}{input dataset. \code{xgb.train} takes only an \code{xgb.DMatrix} as the input.
\code{xgboost}, in addition, also accepts \code{matrix}, \code{dgCMatrix}, or local data file.}
\item{nrounds}{the max number of iterations}
\item{watchlist}{what information should be printed when \code{verbose=1} or
\code{verbose=2}. Watchlist is used to specify validation set monitoring
during training. For example user can specify
watchlist=list(validation1=mat1, validation2=mat2) to watch
the performance of each round's model on mat1 and mat2}
\code{verbose=2}. Watchlist is used to specify validation set monitoring
during training. For example user can specify
watchlist=list(validation1=mat1, validation2=mat2) to watch
the performance of each round's model on mat1 and mat2}
\item{obj}{customized objective function. Returns gradient and second order
gradient with given prediction and dtrain,}
\item{obj}{customized objective function. Returns gradient and second order
gradient with given prediction and dtrain.}
\item{feval}{custimized evaluation function. Returns
\code{list(metric='metric-name', value='metric-value')} with given
prediction and dtrain,}
\item{feval}{custimized evaluation function. Returns
\code{list(metric='metric-name', value='metric-value')} with given
prediction and dtrain.}
\item{verbose}{If 0, xgboost will stay silent. If 1, xgboost will print
information of performance. If 2, xgboost will print information of both}
\item{verbose}{If 0, xgboost will stay silent. If 1, xgboost will print
information of performance. If 2, xgboost will print some additional information.
Setting \code{verbose > 0} automatically engages the \code{\link{cb.evaluation.log}} and
\code{\link{cb.print.evaluation}} callback functions.}
\item{print_every_n}{Print each n-th iteration evaluation messages when \code{verbose>0}.
Default is 1 which means all messages are printed. This parameter is passed to the
\code{\link{cb.print.evaluation}} callback.}
\item{early_stopping_rounds}{If \code{NULL}, the early stopping function is not triggered.
If set to an integer \code{k}, training with a validation set will stop if the performance
doesn't improve for \code{k} rounds.
Setting this parameter engages the \code{\link{cb.early.stop}} callback.}
\item{maximize}{If \code{feval} and \code{early_stopping_rounds} are set,
then this parameter must be set as well.
When it is \code{TRUE}, it means the larger the evaluation score the better.
This parameter is passed to the \code{\link{cb.early.stop}} callback.}
\item{save_period}{when it is non-NULL, model is saved to disk after every \code{save_period} rounds,
0 means save at the end. The saving is handled by the \code{\link{cb.save.model}} callback.}
\item{save_name}{the name or path for periodically saved model file.}
\item{xgb_model}{a previously built model to continue the trainig from.
Could be either an object of class \code{xgb.Booster}, or its raw data, or the name of a
file with a previously saved model.}
\item{callbacks}{a list of callback functions to perform various task during boosting.
See \code{\link{callbacks}}. Some of the callbacks are automatically created depending on the
parameters' values. User can provide either existing or their own callback methods in order
to customize the training process.}
\item{...}{other parameters to pass to \code{params}.}
\item{label}{vector of response values. Should not be provided when data is
a local data file name or an \code{xgb.DMatrix}.}
\item{missing}{by default is set to NA, which means that NA values should be considered as 'missing'
by the algorithm. Sometimes, 0 or other extreme value might be used to represent missing values.
This parameter is only used when input is a dense matrix.}
\item{weight}{a vector indicating the weight for each row of the input.}
}
\value{
An object of class \code{xgb.Booster} with the following elements:
\itemize{
\item \code{handle} a handle (pointer) to the xgboost model in memory.
\item \code{raw} a cached memory dump of the xgboost model saved as R's \code{raw} type.
\item \code{niter} number of boosting iterations.
\item \code{evaluation_log} evaluation history storead as a \code{data.table} with the
first column corresponding to iteration number and the rest corresponding to evaluation
metrics' values. It is created by the \code{\link{cb.evaluation.log}} callback.
\item \code{call} a function call.
\item \code{params} parameters that were passed to the xgboost library. Note that it does not
capture parameters changed by the \code{\link{cb.reset.parameters}} callback.
\item \code{callbacks} callback functions that were either automatically assigned or
explicitely passed.
\item \code{best_iteration} iteration number with the best evaluation metric value
(only available with early stopping).
\item \code{best_ntreelimit} the \code{ntreelimit} value corresponding to the best iteration,
which could further be used in \code{predict} method
(only available with early stopping).
\item \code{best_score} the best evaluation metric value during early stopping.
(only available with early stopping).
}
}
\description{
The training function of xgboost
\code{xgb.train} is an advanced interface for training an xgboost model. The \code{xgboost} function provides a simpler interface.
}
\details{
This is the training function for xgboost.
These are the training functions for \code{xgboost}.
Parallelization is automatically enabled if OpenMP is present.
Number of threads can also be manually specified via "nthread" parameter.
The \code{xgb.train} interface supports advanced features such as \code{watchlist},
customized objective and evaluation metric functions, therefore it is more flexible
than the \code{\link{xgboost}} interface.
This function only accepts an \code{xgb.DMatrix} object as the input.
It supports advanced features such as watchlist, customized objective function,
therefore it is more flexible than \code{\link{xgboost}}.
Parallelization is automatically enabled if \code{OpenMP} is present.
Number of threads can also be manually specified via \code{nthread} parameter.
The evaluation metric is chosen automatically by Xgboost (according to the objective)
when the \code{eval_metric} parameter is not provided.
User may set one or several \code{eval_metric} parameters.
Note that when using a customized metric, only this single metric can be used.
The folloiwing is the list of built-in metrics for which Xgboost provides optimized implementation:
\itemize{
\item \code{rmse} root mean square error. \url{http://en.wikipedia.org/wiki/Root_mean_square_error}
\item \code{logloss} negative log-likelihood. \url{http://en.wikipedia.org/wiki/Log-likelihood}
\item \code{mlogloss} multiclass logloss. \url{https://www.kaggle.com/wiki/MultiClassLogLoss}
\item \code{error} Binary classification error rate. It is calculated as \code{(# wrong cases) / (# all cases)}.
By default, it uses the 0.5 threshold for predicted values to define negative and positive instances.
Different threshold (e.g., 0.) could be specified as "error@0."
\item \code{merror} Multiclass classification error rate. It is calculated as \code{(# wrong cases) / (# all cases)}.
\item \code{auc} Area under the curve. \url{http://en.wikipedia.org/wiki/Receiver_operating_characteristic#'Area_under_curve} for ranking evaluation.
\item \code{ndcg} Normalized Discounted Cumulative Gain (for ranking task). \url{http://en.wikipedia.org/wiki/NDCG}
}
The following callbacks are automatically created when certain parameters are set:
\itemize{
\item \code{cb.print.evaluation} is turned on when \code{verbose > 0};
and the \code{print_every_n} parameter is passed to it.
\item \code{cb.evaluation.log} is on when \code{verbose > 0} and \code{watchlist} is present.
\item \code{cb.early.stop}: when \code{early_stopping_rounds} is set.
\item \code{cb.save.model}: when \code{save_period > 0} is set.
}
}
\examples{
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)
dtest <- dtrain
dtest <- xgb.DMatrix(agaricus.test$data, label = agaricus.test$label)
watchlist <- list(eval = dtest, train = dtrain)
param <- list(max.depth = 2, eta = 1, silent = 1)
## A simple xgb.train example:
param <- list(max_depth = 2, eta = 1, silent = 1,
objective = "binary:logistic", eval_metric = "auc")
bst <- xgb.train(param, dtrain, nthread = 2, nrounds = 2, watchlist)
## An xgb.train example where custom objective and evaluation metric are used:
logregobj <- function(preds, dtrain) {
labels <- getinfo(dtrain, "label")
preds <- 1/(1 + exp(-preds))
@@ -75,6 +217,29 @@ evalerror <- function(preds, dtrain) {
err <- as.numeric(sum(labels != (preds > 0)))/length(labels)
return(list(metric = "error", value = err))
}
bst <- xgb.train(param, dtrain, nround = 2, watchlist, logregobj, evalerror)
bst <- xgb.train(param, dtrain, nthread = 2, nrounds = 2, watchlist)
## An xgb.train example of using variable learning rates at each iteration:
my_etas <- list(eta = c(0.5, 0.1))
bst <- xgb.train(param, dtrain, nthread = 2, nrounds = 2, watchlist,
callbacks = list(cb.reset.parameters(my_etas)))
## Explicit use of the cb.evaluation.log callback allows to run
## xgb.train silently but still store the evaluation results:
bst <- xgb.train(param, dtrain, nthread = 2, nrounds = 2, watchlist,
verbose = 0, callbacks = list(cb.evaluation.log()))
print(bst$evaluation_log)
## An 'xgboost' interface example:
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label,
max_depth = 2, eta = 1, nthread = 2, nrounds = 2,
objective = "binary:logistic")
pred <- predict(bst, agaricus.test$data)
}
\seealso{
\code{\link{callbacks}},
\code{\link{predict.xgb.Booster}},
\code{\link{xgb.cv}}
}

View File

@@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{xgboost-deprecated}
\alias{xgboost-deprecated}
\title{Deprecation notices.}
\description{
At this time, some of the parameter names were changed in order to make the code style more uniform.
The deprecated parameters would be removed in the next release.
}
\details{
To see all the current deprecated and new parameters, check the \code{xgboost:::depr_par_lut} table.
A deprecation warning is shown when any of the deprecated parameters is used in a call.
An additional warning is shown when there was a partial match to a deprecated parameter
(as R is able to partially match parameter names).
}

View File

@@ -1,56 +0,0 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
\name{xgboost}
\alias{xgboost}
\title{eXtreme Gradient Boosting (Tree) library}
\usage{
xgboost(data = NULL, label = NULL, params = list(), nrounds,
verbose = 1, ...)
}
\arguments{
\item{data}{takes \code{matrix}, \code{dgCMatrix}, local data file or
\code{xgb.DMatrix}.}
\item{label}{the response variable. User should not set this field,}
\item{params}{the list of parameters. Commonly used ones are:
\itemize{
\item \code{objective} objective function, common ones are
\itemize{
\item \code{reg:linear} linear regression
\item \code{binary:logistic} logistic regression for classification
}
\item \code{eta} step size of each boosting step
\item \code{max.depth} maximum depth of the tree
\item \code{nthread} number of thread used in training, if not set, all threads are used
}
See \url{https://github.com/tqchen/xgboost/wiki/Parameters} for
further details. See also demo/ for walkthrough example in R.}
\item{nrounds}{the max number of iterations}
\item{verbose}{If 0, xgboost will stay silent. If 1, xgboost will print
information of performance. If 2, xgboost will print information of both
performance and construction progress information}
\item{...}{other parameters to pass to \code{params}.}
}
\description{
A simple interface for xgboost in R
}
\details{
This is the modeling function for xgboost.
Parallelization is automatically enabled if OpenMP is present.
Number of threads can also be manually specified via "nthread" parameter
}
\examples{
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nround = 2,objective = "binary:logistic")
pred <- predict(bst, test$data)
}

View File

@@ -1,9 +1,18 @@
# package root
PKGROOT=../../
ENABLE_STD_THREAD=1
# _*_ mode: Makefile; _*_
PKG_CPPFLAGS= -DXGBOOST_CUSTOMIZE_MSG_ -DXGBOOST_CUSTOMIZE_PRNG_ -DXGBOOST_STRICT_CXX98_ -I$(PKGROOT)
PKG_CXXFLAGS= $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS)
OBJECTS= xgboost_R.o xgboost_assert.o $(PKGROOT)/wrapper/xgboost_wrapper.o $(PKGROOT)/src/io/io.o $(PKGROOT)/src/gbm/gbm.o $(PKGROOT)/src/tree/updater.o
CXX_STD = CXX11
XGB_RFLAGS = -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0\
-DDMLC_ENABLE_STD_THREAD=$(ENABLE_STD_THREAD) -DDMLC_DISABLE_STDIN=1\
-DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1\
-DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_
PKG_CPPFLAGS= -I$(PKGROOT)/include -I$(PKGROOT)/dmlc-core/include -I$(PKGROOT)/rabit/include -I$(PKGROOT) $(XGB_RFLAGS)
PKG_CXXFLAGS= $(SHLIB_OPENMP_CFLAGS) $(SHLIB_PTHREAD_FLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) $(SHLIB_PTHREAD_FLAGS)
OBJECTS= ./xgboost_R.o ./xgboost_custom.o ./xgboost_assert.o\
$(PKGROOT)/amalgamation/xgboost-all0.o $(PKGROOT)/amalgamation/dmlc-minimum0.o\
$(PKGROOT)/rabit/src/engine_empty.o $(PKGROOT)/rabit/src/c_api.o

View File

@@ -1,7 +1,32 @@
# package root
PKGROOT=../../
PKGROOT=./
ENABLE_STD_THREAD=0
# _*_ mode: Makefile; _*_
PKG_CPPFLAGS= -DXGBOOST_CUSTOMIZE_MSG_ -DXGBOOST_CUSTOMIZE_PRNG_ -DXGBOOST_STRICT_CXX98_ -I$(PKGROOT)
PKG_CXXFLAGS= $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS)
OBJECTS= xgboost_R.o xgboost_assert.o $(PKGROOT)/wrapper/xgboost_wrapper.o $(PKGROOT)/src/io/io.o $(PKGROOT)/src/gbm/gbm.o $(PKGROOT)/src/tree/updater.o
# This file is only used for windows compilation from github
# It will be replaced by Makevars in CRAN version
.PHONY: all xgblib
all: $(SHLIB)
$(SHLIB): xgblib
xgblib:
cp -r ../../src .
cp -r ../../rabit .
cp -r ../../dmlc-core .
cp -r ../../include .
cp -r ../../amalgamation .
CXX_STD = CXX11
XGB_RFLAGS = -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0\
-DDMLC_ENABLE_STD_THREAD=$(ENABLE_STD_THREAD) -DDMLC_DISABLE_STDIN=1\
-DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1\
-DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_
PKG_CPPFLAGS= -I$(PKGROOT)/include -I$(PKGROOT)/dmlc-core/include -I$(PKGROOT)/rabit/include -I$(PKGROOT) $(XGB_RFLAGS)
PKG_CXXFLAGS= $(SHLIB_OPENMP_CFLAGS) $(SHLIB_PTHREAD_FLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) $(SHLIB_PTHREAD_FLAGS)
OBJECTS= ./xgboost_R.o ./xgboost_custom.o ./xgboost_assert.o\
$(PKGROOT)/amalgamation/xgboost-all0.o $(PKGROOT)/amalgamation/dmlc-minimum0.o\
$(PKGROOT)/rabit/src/engine_empty.o $(PKGROOT)/rabit/src/c_api.o
$(OBJECTS) : xgblib

419
R-package/src/xgboost_R.cc Normal file
View File

@@ -0,0 +1,419 @@
// Copyright (c) 2014 by Contributors
#include <dmlc/logging.h>
#include <dmlc/omp.h>
#include <xgboost/c_api.h>
#include <vector>
#include <string>
#include <utility>
#include <cstring>
#include <cstdio>
#include <sstream>
#include "./xgboost_R.h"
/*!
* \brief macro to annotate begin of api
*/
#define R_API_BEGIN() \
GetRNGstate(); \
try {
/*!
* \brief macro to annotate end of api
*/
#define R_API_END() \
} catch(dmlc::Error& e) { \
PutRNGstate(); \
error(e.what()); \
} \
PutRNGstate();
/*!
* \brief macro to check the call.
*/
#define CHECK_CALL(x) \
if ((x) != 0) { \
error(XGBGetLastError()); \
}
using namespace dmlc;
SEXP XGCheckNullPtr_R(SEXP handle) {
return ScalarLogical(R_ExternalPtrAddr(handle) == NULL);
}
void _DMatrixFinalizer(SEXP ext) {
R_API_BEGIN();
if (R_ExternalPtrAddr(ext) == NULL) return;
CHECK_CALL(XGDMatrixFree(R_ExternalPtrAddr(ext)));
R_ClearExternalPtr(ext);
R_API_END();
}
SEXP XGDMatrixCreateFromFile_R(SEXP fname, SEXP silent) {
SEXP ret;
R_API_BEGIN();
DMatrixHandle handle;
CHECK_CALL(XGDMatrixCreateFromFile(CHAR(asChar(fname)), asInteger(silent), &handle));
ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
UNPROTECT(1);
R_API_END();
return ret;
}
SEXP XGDMatrixCreateFromMat_R(SEXP mat,
SEXP missing) {
SEXP ret;
R_API_BEGIN();
SEXP dim = getAttrib(mat, R_DimSymbol);
size_t nrow = static_cast<size_t>(INTEGER(dim)[0]);
size_t ncol = static_cast<size_t>(INTEGER(dim)[1]);
double *din = REAL(mat);
std::vector<float> data(nrow * ncol);
#pragma omp parallel for schedule(static)
for (omp_ulong i = 0; i < nrow; ++i) {
for (size_t j = 0; j < ncol; ++j) {
data[i * ncol +j] = din[i + nrow * j];
}
}
DMatrixHandle handle;
CHECK_CALL(XGDMatrixCreateFromMat(BeginPtr(data), nrow, ncol, asReal(missing), &handle));
ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
UNPROTECT(1);
R_API_END();
return ret;
}
SEXP XGDMatrixCreateFromCSC_R(SEXP indptr,
SEXP indices,
SEXP data) {
SEXP ret;
R_API_BEGIN();
const int *p_indptr = INTEGER(indptr);
const int *p_indices = INTEGER(indices);
const double *p_data = REAL(data);
int nindptr = length(indptr);
int ndata = length(data);
std::vector<bst_ulong> col_ptr_(nindptr);
std::vector<unsigned> indices_(ndata);
std::vector<float> data_(ndata);
for (int i = 0; i < nindptr; ++i) {
col_ptr_[i] = static_cast<bst_ulong>(p_indptr[i]);
}
#pragma omp parallel for schedule(static)
for (int i = 0; i < ndata; ++i) {
indices_[i] = static_cast<unsigned>(p_indices[i]);
data_[i] = static_cast<float>(p_data[i]);
}
DMatrixHandle handle;
CHECK_CALL(XGDMatrixCreateFromCSC(BeginPtr(col_ptr_), BeginPtr(indices_),
BeginPtr(data_), nindptr, ndata,
&handle));
ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
UNPROTECT(1);
R_API_END();
return ret;
}
SEXP XGDMatrixSliceDMatrix_R(SEXP handle, SEXP idxset) {
SEXP ret;
R_API_BEGIN();
int len = length(idxset);
std::vector<int> idxvec(len);
for (int i = 0; i < len; ++i) {
idxvec[i] = INTEGER(idxset)[i] - 1;
}
DMatrixHandle res;
CHECK_CALL(XGDMatrixSliceDMatrix(R_ExternalPtrAddr(handle),
BeginPtr(idxvec), len,
&res));
ret = PROTECT(R_MakeExternalPtr(res, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
UNPROTECT(1);
R_API_END();
return ret;
}
SEXP XGDMatrixSaveBinary_R(SEXP handle, SEXP fname, SEXP silent) {
R_API_BEGIN();
CHECK_CALL(XGDMatrixSaveBinary(R_ExternalPtrAddr(handle),
CHAR(asChar(fname)),
asInteger(silent)));
R_API_END();
return R_NilValue;
}
SEXP XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array) {
R_API_BEGIN();
int len = length(array);
const char *name = CHAR(asChar(field));
if (!strcmp("group", name)) {
std::vector<unsigned> vec(len);
#pragma omp parallel for schedule(static)
for (int i = 0; i < len; ++i) {
vec[i] = static_cast<unsigned>(INTEGER(array)[i]);
}
CHECK_CALL(XGDMatrixSetGroup(R_ExternalPtrAddr(handle), BeginPtr(vec), len));
} else {
std::vector<float> vec(len);
#pragma omp parallel for schedule(static)
for (int i = 0; i < len; ++i) {
vec[i] = REAL(array)[i];
}
CHECK_CALL(XGDMatrixSetFloatInfo(R_ExternalPtrAddr(handle),
CHAR(asChar(field)),
BeginPtr(vec), len));
}
R_API_END();
return R_NilValue;
}
SEXP XGDMatrixGetInfo_R(SEXP handle, SEXP field) {
SEXP ret;
R_API_BEGIN();
bst_ulong olen;
const float *res;
CHECK_CALL(XGDMatrixGetFloatInfo(R_ExternalPtrAddr(handle),
CHAR(asChar(field)),
&olen,
&res));
ret = PROTECT(allocVector(REALSXP, olen));
for (size_t i = 0; i < olen; ++i) {
REAL(ret)[i] = res[i];
}
UNPROTECT(1);
R_API_END();
return ret;
}
SEXP XGDMatrixNumRow_R(SEXP handle) {
bst_ulong nrow;
R_API_BEGIN();
CHECK_CALL(XGDMatrixNumRow(R_ExternalPtrAddr(handle), &nrow));
R_API_END();
return ScalarInteger(static_cast<int>(nrow));
}
SEXP XGDMatrixNumCol_R(SEXP handle) {
bst_ulong ncol;
R_API_BEGIN();
CHECK_CALL(XGDMatrixNumCol(R_ExternalPtrAddr(handle), &ncol));
R_API_END();
return ScalarInteger(static_cast<int>(ncol));
}
// functions related to booster
void _BoosterFinalizer(SEXP ext) {
if (R_ExternalPtrAddr(ext) == NULL) return;
CHECK_CALL(XGBoosterFree(R_ExternalPtrAddr(ext)));
R_ClearExternalPtr(ext);
}
SEXP XGBoosterCreate_R(SEXP dmats) {
SEXP ret;
R_API_BEGIN();
int len = length(dmats);
std::vector<void*> dvec;
for (int i = 0; i < len; ++i) {
dvec.push_back(R_ExternalPtrAddr(VECTOR_ELT(dmats, i)));
}
BoosterHandle handle;
CHECK_CALL(XGBoosterCreate(BeginPtr(dvec), dvec.size(), &handle));
ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _BoosterFinalizer, TRUE);
UNPROTECT(1);
R_API_END();
return ret;
}
SEXP XGBoosterSetParam_R(SEXP handle, SEXP name, SEXP val) {
R_API_BEGIN();
CHECK_CALL(XGBoosterSetParam(R_ExternalPtrAddr(handle),
CHAR(asChar(name)),
CHAR(asChar(val))));
R_API_END();
return R_NilValue;
}
SEXP XGBoosterUpdateOneIter_R(SEXP handle, SEXP iter, SEXP dtrain) {
R_API_BEGIN();
CHECK_CALL(XGBoosterUpdateOneIter(R_ExternalPtrAddr(handle),
asInteger(iter),
R_ExternalPtrAddr(dtrain)));
R_API_END();
return R_NilValue;
}
SEXP XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess) {
R_API_BEGIN();
CHECK_EQ(length(grad), length(hess))
<< "gradient and hess must have same length";
int len = length(grad);
std::vector<float> tgrad(len), thess(len);
#pragma omp parallel for schedule(static)
for (int j = 0; j < len; ++j) {
tgrad[j] = REAL(grad)[j];
thess[j] = REAL(hess)[j];
}
CHECK_CALL(XGBoosterBoostOneIter(R_ExternalPtrAddr(handle),
R_ExternalPtrAddr(dtrain),
BeginPtr(tgrad), BeginPtr(thess),
len));
R_API_END();
return R_NilValue;
}
SEXP XGBoosterEvalOneIter_R(SEXP handle, SEXP iter, SEXP dmats, SEXP evnames) {
const char *ret;
R_API_BEGIN();
CHECK_EQ(length(dmats), length(evnames))
<< "dmats and evnams must have same length";
int len = length(dmats);
std::vector<void*> vec_dmats;
std::vector<std::string> vec_names;
std::vector<const char*> vec_sptr;
for (int i = 0; i < len; ++i) {
vec_dmats.push_back(R_ExternalPtrAddr(VECTOR_ELT(dmats, i)));
vec_names.push_back(std::string(CHAR(asChar(VECTOR_ELT(evnames, i)))));
}
for (int i = 0; i < len; ++i) {
vec_sptr.push_back(vec_names[i].c_str());
}
CHECK_CALL(XGBoosterEvalOneIter(R_ExternalPtrAddr(handle),
asInteger(iter),
BeginPtr(vec_dmats),
BeginPtr(vec_sptr),
len, &ret));
R_API_END();
return mkString(ret);
}
SEXP XGBoosterPredict_R(SEXP handle, SEXP dmat, SEXP option_mask, SEXP ntree_limit) {
SEXP ret;
R_API_BEGIN();
bst_ulong olen;
const float *res;
CHECK_CALL(XGBoosterPredict(R_ExternalPtrAddr(handle),
R_ExternalPtrAddr(dmat),
asInteger(option_mask),
asInteger(ntree_limit),
&olen, &res));
ret = PROTECT(allocVector(REALSXP, olen));
for (size_t i = 0; i < olen; ++i) {
REAL(ret)[i] = res[i];
}
UNPROTECT(1);
R_API_END();
return ret;
}
SEXP XGBoosterLoadModel_R(SEXP handle, SEXP fname) {
R_API_BEGIN();
CHECK_CALL(XGBoosterLoadModel(R_ExternalPtrAddr(handle), CHAR(asChar(fname))));
R_API_END();
return R_NilValue;
}
SEXP XGBoosterSaveModel_R(SEXP handle, SEXP fname) {
R_API_BEGIN();
CHECK_CALL(XGBoosterSaveModel(R_ExternalPtrAddr(handle), CHAR(asChar(fname))));
R_API_END();
return R_NilValue;
}
SEXP XGBoosterLoadModelFromRaw_R(SEXP handle, SEXP raw) {
R_API_BEGIN();
CHECK_CALL(XGBoosterLoadModelFromBuffer(R_ExternalPtrAddr(handle),
RAW(raw),
length(raw)));
R_API_END();
return R_NilValue;
}
SEXP XGBoosterModelToRaw_R(SEXP handle) {
SEXP ret;
R_API_BEGIN();
bst_ulong olen;
const char *raw;
CHECK_CALL(XGBoosterGetModelRaw(R_ExternalPtrAddr(handle), &olen, &raw));
ret = PROTECT(allocVector(RAWSXP, olen));
if (olen != 0) {
memcpy(RAW(ret), raw, olen);
}
UNPROTECT(1);
R_API_END();
return ret;
}
SEXP XGBoosterDumpModel_R(SEXP handle, SEXP fmap, SEXP with_stats) {
SEXP out;
R_API_BEGIN();
bst_ulong olen;
const char **res;
CHECK_CALL(XGBoosterDumpModel(R_ExternalPtrAddr(handle),
CHAR(asChar(fmap)),
asInteger(with_stats),
&olen, &res));
out = PROTECT(allocVector(STRSXP, olen));
for (size_t i = 0; i < olen; ++i) {
std::stringstream stream;
stream << "booster[" << i <<"]\n" << res[i];
SET_STRING_ELT(out, i, mkChar(stream.str().c_str()));
}
UNPROTECT(1);
R_API_END();
return out;
}
SEXP XGBoosterGetAttr_R(SEXP handle, SEXP name) {
SEXP out;
R_API_BEGIN();
int success;
const char *val;
CHECK_CALL(XGBoosterGetAttr(R_ExternalPtrAddr(handle),
CHAR(asChar(name)),
&val,
&success));
if (success) {
out = PROTECT(allocVector(STRSXP, 1));
SET_STRING_ELT(out, 0, mkChar(val));
} else {
out = PROTECT(R_NilValue);
}
UNPROTECT(1);
R_API_END();
return out;
}
SEXP XGBoosterSetAttr_R(SEXP handle, SEXP name, SEXP val) {
R_API_BEGIN();
const char *v = isNull(val) ? nullptr : CHAR(asChar(val));
CHECK_CALL(XGBoosterSetAttr(R_ExternalPtrAddr(handle),
CHAR(asChar(name)), v));
R_API_END();
return R_NilValue;
}
SEXP XGBoosterGetAttrNames_R(SEXP handle) {
SEXP out;
R_API_BEGIN();
bst_ulong len;
const char **res;
CHECK_CALL(XGBoosterGetAttrNames(R_ExternalPtrAddr(handle),
&len, &res));
if (len > 0) {
out = PROTECT(allocVector(STRSXP, len));
for (size_t i = 0; i < len; ++i) {
SET_STRING_ELT(out, i, mkChar(res[i]));
}
} else {
out = PROTECT(R_NilValue);
}
UNPROTECT(1);
R_API_END();
return out;
}

View File

@@ -1,289 +0,0 @@
#include <vector>
#include <string>
#include <utility>
#include <cstring>
#include <cstdio>
#include "xgboost_R.h"
#include "wrapper/xgboost_wrapper.h"
#include "src/utils/utils.h"
#include "src/utils/omp.h"
using namespace std;
using namespace xgboost;
extern "C" {
void XGBoostAssert_R(int exp, const char *fmt, ...);
void XGBoostCheck_R(int exp, const char *fmt, ...);
int XGBoostSPrintf_R(char *buf, size_t size, const char *fmt, ...);
}
// implements error handling
namespace xgboost {
namespace utils {
extern "C" {
void (*Printf)(const char *fmt, ...) = Rprintf;
int (*SPrintf)(char *buf, size_t size, const char *fmt, ...) = XGBoostSPrintf_R;
void (*Assert)(int exp, const char *fmt, ...) = XGBoostAssert_R;
void (*Check)(int exp, const char *fmt, ...) = XGBoostCheck_R;
void (*Error)(const char *fmt, ...) = error;
}
} // namespace utils
namespace random {
void Seed(unsigned seed) {
warning("parameter seed is ignored, please set random seed using set.seed");
}
double Uniform(void) {
return unif_rand();
}
double Normal(void) {
return norm_rand();
}
} // namespace random
} // namespace xgboost
// call before wrapper starts
inline void _WrapperBegin(void) {
GetRNGstate();
}
// call after wrapper starts
inline void _WrapperEnd(void) {
PutRNGstate();
}
extern "C" {
void _DMatrixFinalizer(SEXP ext) {
if (R_ExternalPtrAddr(ext) == NULL) return;
XGDMatrixFree(R_ExternalPtrAddr(ext));
R_ClearExternalPtr(ext);
}
SEXP XGDMatrixCreateFromFile_R(SEXP fname, SEXP silent) {
_WrapperBegin();
void *handle = XGDMatrixCreateFromFile(CHAR(asChar(fname)), asInteger(silent));
SEXP ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
UNPROTECT(1);
_WrapperEnd();
return ret;
}
SEXP XGDMatrixCreateFromMat_R(SEXP mat,
SEXP missing) {
_WrapperBegin();
SEXP dim = getAttrib(mat, R_DimSymbol);
int nrow = INTEGER(dim)[0];
int ncol = INTEGER(dim)[1];
double *din = REAL(mat);
std::vector<float> data(nrow * ncol);
#pragma omp parallel for schedule(static)
for (int i = 0; i < nrow; ++i) {
for (int j = 0; j < ncol; ++j) {
data[i * ncol +j] = din[i + nrow * j];
}
}
void *handle = XGDMatrixCreateFromMat(BeginPtr(data), nrow, ncol, asReal(missing));
SEXP ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
UNPROTECT(1);
_WrapperEnd();
return ret;
}
SEXP XGDMatrixCreateFromCSC_R(SEXP indptr,
SEXP indices,
SEXP data) {
_WrapperBegin();
const int *p_indptr = INTEGER(indptr);
const int *p_indices = INTEGER(indices);
const double *p_data = REAL(data);
int nindptr = length(indptr);
int ndata = length(data);
std::vector<bst_ulong> col_ptr_(nindptr);
std::vector<unsigned> indices_(ndata);
std::vector<float> data_(ndata);
for (int i = 0; i < nindptr; ++i) {
col_ptr_[i] = static_cast<bst_ulong>(p_indptr[i]);
}
#pragma omp parallel for schedule(static)
for (int i = 0; i < ndata; ++i) {
indices_[i] = static_cast<unsigned>(p_indices[i]);
data_[i] = static_cast<float>(p_data[i]);
}
void *handle = XGDMatrixCreateFromCSC(BeginPtr(col_ptr_), BeginPtr(indices_),
BeginPtr(data_), nindptr, ndata);
SEXP ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
UNPROTECT(1);
_WrapperEnd();
return ret;
}
SEXP XGDMatrixSliceDMatrix_R(SEXP handle, SEXP idxset) {
_WrapperBegin();
int len = length(idxset);
std::vector<int> idxvec(len);
for (int i = 0; i < len; ++i) {
idxvec[i] = INTEGER(idxset)[i] - 1;
}
void *res = XGDMatrixSliceDMatrix(R_ExternalPtrAddr(handle), BeginPtr(idxvec), len);
SEXP ret = PROTECT(R_MakeExternalPtr(res, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
UNPROTECT(1);
_WrapperEnd();
return ret;
}
void XGDMatrixSaveBinary_R(SEXP handle, SEXP fname, SEXP silent) {
_WrapperBegin();
XGDMatrixSaveBinary(R_ExternalPtrAddr(handle),
CHAR(asChar(fname)), asInteger(silent));
_WrapperEnd();
}
void XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array) {
_WrapperBegin();
int len = length(array);
const char *name = CHAR(asChar(field));
if (!strcmp("group", name)) {
std::vector<unsigned> vec(len);
#pragma omp parallel for schedule(static)
for (int i = 0; i < len; ++i) {
vec[i] = static_cast<unsigned>(INTEGER(array)[i]);
}
XGDMatrixSetGroup(R_ExternalPtrAddr(handle), BeginPtr(vec), len);
_WrapperEnd();
return;
}
{
std::vector<float> vec(len);
#pragma omp parallel for schedule(static)
for (int i = 0; i < len; ++i) {
vec[i] = REAL(array)[i];
}
XGDMatrixSetFloatInfo(R_ExternalPtrAddr(handle),
CHAR(asChar(field)),
BeginPtr(vec), len);
}
_WrapperEnd();
}
SEXP XGDMatrixGetInfo_R(SEXP handle, SEXP field) {
_WrapperBegin();
bst_ulong olen;
const float *res = XGDMatrixGetFloatInfo(R_ExternalPtrAddr(handle),
CHAR(asChar(field)), &olen);
SEXP ret = PROTECT(allocVector(REALSXP, olen));
for (size_t i = 0; i < olen; ++i) {
REAL(ret)[i] = res[i];
}
UNPROTECT(1);
_WrapperEnd();
return ret;
}
SEXP XGDMatrixNumRow_R(SEXP handle) {
bst_ulong nrow = XGDMatrixNumRow(R_ExternalPtrAddr(handle));
return ScalarInteger(static_cast<int>(nrow));
}
// functions related to booster
void _BoosterFinalizer(SEXP ext) {
if (R_ExternalPtrAddr(ext) == NULL) return;
XGBoosterFree(R_ExternalPtrAddr(ext));
R_ClearExternalPtr(ext);
}
SEXP XGBoosterCreate_R(SEXP dmats) {
_WrapperBegin();
int len = length(dmats);
std::vector<void*> dvec;
for (int i = 0; i < len; ++i){
dvec.push_back(R_ExternalPtrAddr(VECTOR_ELT(dmats, i)));
}
void *handle = XGBoosterCreate(BeginPtr(dvec), dvec.size());
SEXP ret = PROTECT(R_MakeExternalPtr(handle, R_NilValue, R_NilValue));
R_RegisterCFinalizerEx(ret, _BoosterFinalizer, TRUE);
UNPROTECT(1);
_WrapperEnd();
return ret;
}
void XGBoosterSetParam_R(SEXP handle, SEXP name, SEXP val) {
_WrapperBegin();
XGBoosterSetParam(R_ExternalPtrAddr(handle),
CHAR(asChar(name)),
CHAR(asChar(val)));
_WrapperEnd();
}
void XGBoosterUpdateOneIter_R(SEXP handle, SEXP iter, SEXP dtrain) {
_WrapperBegin();
XGBoosterUpdateOneIter(R_ExternalPtrAddr(handle),
asInteger(iter),
R_ExternalPtrAddr(dtrain));
_WrapperEnd();
}
void XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess) {
_WrapperBegin();
utils::Check(length(grad) == length(hess), "gradient and hess must have same length");
int len = length(grad);
std::vector<float> tgrad(len), thess(len);
#pragma omp parallel for schedule(static)
for (int j = 0; j < len; ++j) {
tgrad[j] = REAL(grad)[j];
thess[j] = REAL(hess)[j];
}
XGBoosterBoostOneIter(R_ExternalPtrAddr(handle),
R_ExternalPtrAddr(dtrain),
BeginPtr(tgrad), BeginPtr(thess), len);
_WrapperEnd();
}
SEXP XGBoosterEvalOneIter_R(SEXP handle, SEXP iter, SEXP dmats, SEXP evnames) {
_WrapperBegin();
utils::Check(length(dmats) == length(evnames), "dmats and evnams must have same length");
int len = length(dmats);
std::vector<void*> vec_dmats;
std::vector<std::string> vec_names;
std::vector<const char*> vec_sptr;
for (int i = 0; i < len; ++i) {
vec_dmats.push_back(R_ExternalPtrAddr(VECTOR_ELT(dmats, i)));
vec_names.push_back(std::string(CHAR(asChar(VECTOR_ELT(evnames, i)))));
}
for (int i = 0; i < len; ++i) {
vec_sptr.push_back(vec_names[i].c_str());
}
return mkString(XGBoosterEvalOneIter(R_ExternalPtrAddr(handle),
asInteger(iter),
BeginPtr(vec_dmats), BeginPtr(vec_sptr), len));
_WrapperEnd();
}
SEXP XGBoosterPredict_R(SEXP handle, SEXP dmat, SEXP output_margin, SEXP ntree_limit) {
_WrapperBegin();
bst_ulong olen;
const float *res = XGBoosterPredict(R_ExternalPtrAddr(handle),
R_ExternalPtrAddr(dmat),
asInteger(output_margin),
asInteger(ntree_limit),
&olen);
SEXP ret = PROTECT(allocVector(REALSXP, olen));
for (size_t i = 0; i < olen; ++i) {
REAL(ret)[i] = res[i];
}
UNPROTECT(1);
_WrapperEnd();
return ret;
}
void XGBoosterLoadModel_R(SEXP handle, SEXP fname) {
_WrapperBegin();
XGBoosterLoadModel(R_ExternalPtrAddr(handle), CHAR(asChar(fname)));
_WrapperEnd();
}
void XGBoosterSaveModel_R(SEXP handle, SEXP fname) {
_WrapperBegin();
XGBoosterSaveModel(R_ExternalPtrAddr(handle), CHAR(asChar(fname)));
_WrapperEnd();
}
void XGBoosterDumpModel_R(SEXP handle, SEXP fname, SEXP fmap) {
_WrapperBegin();
bst_ulong olen;
const char **res = XGBoosterDumpModel(R_ExternalPtrAddr(handle),
CHAR(asChar(fmap)),
&olen);
FILE *fo = utils::FopenCheck(CHAR(asChar(fname)), "w");
for (size_t i = 0; i < olen; ++i) {
fprintf(fo, "booster[%u]:\n", static_cast<unsigned>(i));
fprintf(fo, "%s", res[i]);
}
fclose(fo);
_WrapperEnd();
}
}

View File

@@ -1,138 +1,212 @@
#ifndef XGBOOST_WRAPPER_R_H_
#define XGBOOST_WRAPPER_R_H_
/*!
* Copyright 2014 (c) by Contributors
* \file xgboost_wrapper_R.h
* \author Tianqi Chen
* \brief R wrapper of xgboost
*/
extern "C" {
#ifndef XGBOOST_R_H_ // NOLINT(*)
#define XGBOOST_R_H_ // NOLINT(*)
#include <Rinternals.h>
#include <R_ext/Random.h>
}
#include <Rmath.h>
extern "C" {
/*!
* \brief load a data matrix
* \param fname name of the content
* \param silent whether print messages
* \return a loaded data matrix
#include <xgboost/c_api.h>
/*!
* \brief check whether a handle is NULL
* \param handle
* \return whether it is null ptr
*/
XGB_DLL SEXP XGCheckNullPtr_R(SEXP handle);
/*!
* \brief load a data matrix
* \param fname name of the content
* \param silent whether print messages
* \return a loaded data matrix
*/
XGB_DLL SEXP XGDMatrixCreateFromFile_R(SEXP fname, SEXP silent);
/*!
* \brief create matrix content from dense matrix
* This assumes the matrix is stored in column major format
* \param data R Matrix object
* \param missing which value to represent missing value
* \return created dmatrix
*/
XGB_DLL SEXP XGDMatrixCreateFromMat_R(SEXP mat,
SEXP missing);
/*!
* \brief create a matrix content from CSC format
* \param indptr pointer to column headers
* \param indices row indices
* \param data content of the data
* \return created dmatrix
*/
XGB_DLL SEXP XGDMatrixCreateFromCSC_R(SEXP indptr,
SEXP indices,
SEXP data);
/*!
* \brief create a new dmatrix from sliced content of existing matrix
* \param handle instance of data matrix to be sliced
* \param idxset index set
* \return a sliced new matrix
*/
XGB_DLL SEXP XGDMatrixSliceDMatrix_R(SEXP handle, SEXP idxset);
/*!
* \brief load a data matrix into binary file
* \param handle a instance of data matrix
* \param fname file name
* \param silent print statistics when saving
* \return R_NilValue
*/
XGB_DLL SEXP XGDMatrixSaveBinary_R(SEXP handle, SEXP fname, SEXP silent);
/*!
* \brief set information to dmatrix
* \param handle a instance of data matrix
* \param field field name, can be label, weight
* \param array pointer to float vector
* \return R_NilValue
*/
XGB_DLL SEXP XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array);
/*!
* \brief get info vector from matrix
* \param handle a instance of data matrix
* \param field field name
* \return info vector
*/
XGB_DLL SEXP XGDMatrixGetInfo_R(SEXP handle, SEXP field);
/*!
* \brief return number of rows
* \param handle an instance of data matrix
*/
XGB_DLL SEXP XGDMatrixNumRow_R(SEXP handle);
/*!
* \brief return number of columns
* \param handle an instance of data matrix
*/
XGB_DLL SEXP XGDMatrixNumCol_R(SEXP handle);
/*!
* \brief create xgboost learner
* \param dmats a list of dmatrix handles that will be cached
*/
XGB_DLL SEXP XGBoosterCreate_R(SEXP dmats);
/*!
* \brief set parameters
* \param handle handle
* \param name parameter name
* \param val value of parameter
* \return R_NilValue
*/
XGB_DLL SEXP XGBoosterSetParam_R(SEXP handle, SEXP name, SEXP val);
/*!
* \brief update the model in one round using dtrain
* \param handle handle
* \param iter current iteration rounds
* \param dtrain training data
* \return R_NilValue
*/
XGB_DLL SEXP XGBoosterUpdateOneIter_R(SEXP ext, SEXP iter, SEXP dtrain);
/*!
* \brief update the model, by directly specify gradient and second order gradient,
* this can be used to replace UpdateOneIter, to support customized loss function
* \param handle handle
* \param dtrain training data
* \param grad gradient statistics
* \param hess second order gradient statistics
* \return R_NilValue
*/
XGB_DLL SEXP XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess);
/*!
* \brief get evaluation statistics for xgboost
* \param handle handle
* \param iter current iteration rounds
* \param dmats list of handles to dmatrices
* \param evname name of evaluation
* \return the string containing evaluation stats
*/
XGB_DLL SEXP XGBoosterEvalOneIter_R(SEXP handle, SEXP iter, SEXP dmats, SEXP evnames);
/*!
* \brief make prediction based on dmat
* \param handle handle
* \param dmat data matrix
* \param option_mask output_margin:1 predict_leaf:2
* \param ntree_limit limit number of trees used in prediction
*/
XGB_DLL SEXP XGBoosterPredict_R(SEXP handle, SEXP dmat, SEXP option_mask, SEXP ntree_limit);
/*!
* \brief load model from existing file
* \param handle handle
* \param fname file name
* \return R_NilValue
*/
XGB_DLL SEXP XGBoosterLoadModel_R(SEXP handle, SEXP fname);
/*!
* \brief save model into existing file
* \param handle handle
* \param fname file name
* \return R_NilValue
*/
XGB_DLL SEXP XGBoosterSaveModel_R(SEXP handle, SEXP fname);
/*!
* \brief load model from raw array
* \param handle handle
* \return R_NilValue
*/
XGB_DLL SEXP XGBoosterLoadModelFromRaw_R(SEXP handle, SEXP raw);
/*!
* \brief save model into R's raw array
* \param handle handle
* \return raw array
*/
SEXP XGDMatrixCreateFromFile_R(SEXP fname, SEXP silent);
/*!
* \brief create matrix content from dense matrix
* This assumes the matrix is stored in column major format
* \param data R Matrix object
* \param missing which value to represent missing value
* \return created dmatrix
*/
SEXP XGDMatrixCreateFromMat_R(SEXP mat,
SEXP missing);
/*!
* \brief create a matrix content from CSC format
* \param indptr pointer to column headers
* \param indices row indices
* \param data content of the data
* \return created dmatrix
*/
SEXP XGDMatrixCreateFromCSC_R(SEXP indptr,
SEXP indices,
SEXP data);
/*!
* \brief create a new dmatrix from sliced content of existing matrix
* \param handle instance of data matrix to be sliced
* \param idxset index set
* \return a sliced new matrix
*/
SEXP XGDMatrixSliceDMatrix_R(SEXP handle, SEXP idxset);
/*!
* \brief load a data matrix into binary file
* \param handle a instance of data matrix
* \param fname file name
* \param silent print statistics when saving
*/
void XGDMatrixSaveBinary_R(SEXP handle, SEXP fname, SEXP silent);
/*!
* \brief set information to dmatrix
* \param handle a instance of data matrix
* \param field field name, can be label, weight
* \param array pointer to float vector
*/
void XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array);
/*!
* \brief get info vector from matrix
* \param handle a instance of data matrix
* \param field field name
* \return info vector
*/
SEXP XGDMatrixGetInfo_R(SEXP handle, SEXP field);
/*!
* \brief return number of rows
* \param handle a instance of data matrix
*/
SEXP XGDMatrixNumRow_R(SEXP handle);
/*!
* \brief create xgboost learner
* \param dmats a list of dmatrix handles that will be cached
*/
SEXP XGBoosterCreate_R(SEXP dmats);
/*!
* \brief set parameters
* \param handle handle
* \param name parameter name
* \param val value of parameter
*/
void XGBoosterSetParam_R(SEXP handle, SEXP name, SEXP val);
/*!
* \brief update the model in one round using dtrain
* \param handle handle
* \param iter current iteration rounds
* \param dtrain training data
*/
void XGBoosterUpdateOneIter_R(SEXP ext, SEXP iter, SEXP dtrain);
/*!
* \brief update the model, by directly specify gradient and second order gradient,
* this can be used to replace UpdateOneIter, to support customized loss function
* \param handle handle
* \param dtrain training data
* \param grad gradient statistics
* \param hess second order gradient statistics
*/
void XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess);
/*!
* \brief get evaluation statistics for xgboost
* \param handle handle
* \param iter current iteration rounds
* \param dmats list of handles to dmatrices
* \param evname name of evaluation
* \return the string containing evaluation stati
*/
SEXP XGBoosterEvalOneIter_R(SEXP handle, SEXP iter, SEXP dmats, SEXP evnames);
/*!
* \brief make prediction based on dmat
* \param handle handle
* \param dmat data matrix
* \param output_margin whether only output raw margin value
* \param ntree_limit limit number of trees used in prediction
*/
SEXP XGBoosterPredict_R(SEXP handle, SEXP dmat, SEXP output_margin, SEXP ntree_limit);
/*!
* \brief load model from existing file
* \param handle handle
* \param fname file name
*/
void XGBoosterLoadModel_R(SEXP handle, SEXP fname);
/*!
* \brief save model into existing file
* \param handle handle
* \param fname file name
*/
void XGBoosterSaveModel_R(SEXP handle, SEXP fname);
/*!
* \brief dump model into text file
* \param handle handle
* \param fname file name of model that can be dumped into
* \param fmap name to fmap can be empty string
*/
void XGBoosterDumpModel_R(SEXP handle, SEXP fname, SEXP fmap);
}
#endif // XGBOOST_WRAPPER_R_H_
XGB_DLL SEXP XGBoosterModelToRaw_R(SEXP handle);
/*!
* \brief dump model into a string
* \param handle handle
* \param fmap name to fmap can be empty string
* \param with_stats whether dump statistics of splits
*/
XGB_DLL SEXP XGBoosterDumpModel_R(SEXP handle, SEXP fmap, SEXP with_stats);
/*!
* \brief get learner attribute value
* \param handle handle
* \param name attribute name
* \return character containing attribute value
*/
XGB_DLL SEXP XGBoosterGetAttr_R(SEXP handle, SEXP name);
/*!
* \brief set learner attribute value
* \param handle handle
* \param name attribute name
* \param val attribute value; NULL value would delete an attribute
* \return R_NilValue
*/
XGB_DLL SEXP XGBoosterSetAttr_R(SEXP handle, SEXP name, SEXP val);
/*!
* \brief get the names of learner attributes
* \return string vector containing attribute names
*/
XGB_DLL SEXP XGBoosterGetAttrNames_R(SEXP handle);
#endif // XGBOOST_WRAPPER_R_H_ // NOLINT(*)

View File

@@ -1,3 +1,4 @@
// Copyright (c) 2014 by Contributors
#include <stdio.h>
#include <stdarg.h>
#include <Rinternals.h>
@@ -6,28 +7,20 @@
void XGBoostAssert_R(int exp, const char *fmt, ...) {
char buf[1024];
if (exp == 0) {
va_list args;
va_list args;
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
error("AssertError:%s\n", buf);
}
}
}
void XGBoostCheck_R(int exp, const char *fmt, ...) {
char buf[1024];
if (exp == 0) {
va_list args;
va_list args;
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
error("%s\n", buf);
}
}
int XGBoostSPrintf_R(char *buf, size_t size, const char *fmt, ...) {
int ret;
va_list args;
va_start(args, fmt);
ret = vsnprintf(buf, size, fmt, args);
va_end(args);
return ret;
}

View File

@@ -0,0 +1,65 @@
// Copyright (c) 2015 by Contributors
// This file contains the customization implementations of R module
// to change behavior of libxgboost
#include <xgboost/logging.h>
#include "src/common/random.h"
#include "./xgboost_R.h"
// redirect the messages to R's console.
namespace dmlc {
void CustomLogMessage::Log(const std::string& msg) {
Rprintf("%s\n", msg.c_str());
}
} // namespace dmlc
// implements rabit error handling.
extern "C" {
void XGBoostAssert_R(int exp, const char *fmt, ...);
void XGBoostCheck_R(int exp, const char *fmt, ...);
}
namespace rabit {
namespace utils {
extern "C" {
void (*Printf)(const char *fmt, ...) = Rprintf;
void (*Assert)(int exp, const char *fmt, ...) = XGBoostAssert_R;
void (*Check)(int exp, const char *fmt, ...) = XGBoostCheck_R;
void (*Error)(const char *fmt, ...) = error;
}
}
}
namespace xgboost {
ConsoleLogger::~ConsoleLogger() {
dmlc::CustomLogMessage::Log(log_stream_.str());
}
TrackerLogger::~TrackerLogger() {
dmlc::CustomLogMessage::Log(log_stream_.str());
}
} // namespace xgboost
namespace xgboost {
namespace common {
// redirect the nath functions.
bool CheckNAN(double v) {
return ISNAN(v);
}
double LogGamma(double v) {
return lgammafn(v);
}
// customize random engine.
void CustomGlobalRandomEngine::seed(CustomGlobalRandomEngine::result_type val) {
// ignore the seed
}
// use R's PRNG to replacd
CustomGlobalRandomEngine::result_type
CustomGlobalRandomEngine::operator()() {
return static_cast<result_type>(
std::floor(unif_rand() * CustomGlobalRandomEngine::max()));
}
} // namespace common
} // namespace xgboost

View File

@@ -0,0 +1,4 @@
library(testthat)
library(xgboost)
test_check("xgboost")

Some files were not shown because too many files have changed in this diff Show More