์ ๋ 1๋จ๊ณ ์ฆ๋ถ XGBoost ์์๋ธ ๊ตฌ์ฑ์ ์คํํ๊ณ ์์์ต๋๋ค. Booster๊ฐ xgboost.train ํจ์( python library )์ ์ํด ์์ฑ๋๋ฉด ๋ชจ๋ ๊ฒ์ด ์ ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
๊ทธ๋ฌ๋ ๋ถ์คํฐ๋ฅผ ์์ฑํ๊ณ ๋ค์ ๊ณผ ๊ฐ์ด
```ํ์ด์ฌ
booster_ = xgboost.Booster({'๋ชฉํ': 'reg:linear'})
booster_.update(dtrain, 1)
the python process fails with a segmentation fault.
## Environment info
Operating System:
* **python 3.6** Mac OS X 10.10.5 (Darwin 14.5.0), Ubuntu 14.04.5 LTS (GNU/Linux 3.19.0-25-generic x86_64);
* **python 2.7** Mac OS X 10.10.6 (Darwin 15.6.0);
Compiler:
* **python 3.6** used `pip install xgboost`;
* **python 2.7** gcc (6.3.0 --without-multilib);
`xgboost` version used:
* **python 3.6** version 0.6 from pip;
* **python 2.7.13** git HEAD 4a63f4ab43480adaaf13bde2485d5bfedd952520;
## Steps to reproduce
```python
import xgboost
dtrain = xgboost.DMatrix(data=[[-1.0], [0.0], [1.0]], label=[0.0, -1.0, 1.0])
booster_ = xgboost.Booster({'objective': 'reg:linear', 'max_depth': 1})
booster_.update(dtrain, 1)
booster_.update(dtrain, 1)
๋ง์ง๋ง ์ค์ ๋ถํ ์ค๋ฅ๋ฅผ ์ผ์ผํต๋๋ค. python 2.7.13 ์ ๋ํ
์ ์ํด ๋ฐํ๋ ๋น Booster ๊ฐ์ฒด์ ์ฆ๋ถ ์ ๋ฐ์ดํธ๋ฅผ ์ํํ์ฌ ๋ด ๊ธฐ๋์น๊ฐ ๋ฌด์์ธ์ง ๋ช ํํ ํ๊ณ ์ถ์ต๋๋ค.
booster_ = xgboost.Booster({'objective': 'reg:linear', 'max_depth': 1})
์ผ๋ฐ์ ์ธ ๊ทธ๋๋์ธํธ ๋ถ์คํ
์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋ฅด๋ฉด DMatrix dtrain
์์ ์ํ(X, y)์ ์
๋ฐ์ดํธํ ํ
booster_.update(dtrain, 1)
๋น ๋ถ์คํฐ๋ f_0(x)
-- ์์ ์์ธก ๋๋ f_1(x)
-- ์๋์ ํ์๋ ๊ฒ์ฒ๋ผ ๊ทธ๋๋์ธํธ ๋ถ์คํ
์ ํ ๋จ๊ณ ํ ์์ธก์ด ๋ฉ๋๋ค(from Hastie, Tibshirani, Friedman; 2013 10th ed page 361).
๋๋ ๋ฌธ์ ๋ฅผ ์ฌํ ์์ ์์ ์ ๊ณตํ๋ ๋น RegTree::FVec.data
๋ฒกํฐ๊น์ง ์ถ์ ํ ์ ์์์ต๋๋ค. booster_.update
์ ๋ํ ๋ ๋ฒ์งธ ํธ์ถ์ (์๋) ์ถ์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
this->UpdateOneIter(...);
this->PredictRaw(train, &preds_);
gbm_->Predict(data, out_preds, ntree_limit=0);
PredLoopInternal<GBTree>(p_fmat, out_preds, 0, ntree_limit, true);
PredValue(inst, gid, info.GetRoot(ridx), &feats, tree_begin, tree_end);
int tid = trees[i]->GetLeafIndex(*p_feats, root_index);
์ฌ๊ธฐ์ ์คํจ:
ํฌํจ/xgboost/tree_model.h:#L528
..., feat.fvalue(split_index), feat.is_missing(split_index), ...
feat.data.size() == 0
๊ฒ ๊ฐ์ต๋๋ค. .update()
๋ํ ์ฒซ ๋ฒ์งธ ํธ์ถ ํ์ ์ด ๋ฒกํฐ๊ฐ ์ฌ์ ํ ๋น์ด ์์ง๋ง .train()
๋ํ ๋์ฒด ํธ์ถ ํ์ ๋น์ด ์์ง ์์ ์ด์ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
๋ฌธ์ ์ ์์ธ์ด ๋ฌด์์ธ์ง ์์๋์ต๋๋ค. ๋๋ ๋ค์์ ํธ์ถํ์ฌ ๋น ๋ถ์คํฐ๋ฅผ ๋ง๋๋ ๊ฒ์ผ๋ก ๋ํ๋ฌ์ต๋๋ค.
booster_ = xgboost.Booster({'objective': 'reg:linear'})
GBTree ๋ถ์คํฐ๋ฅผ ๋ถ๋ถ์ ์ผ๋ก๋ง ์ด๊ธฐํํฉ๋๋ค. ํนํ ์ค์ํ ๋งค๊ฐ๋ณ์ num_feature
๊ธฐ๋ณธ์ ์ผ๋ก 0์ผ๋ก ์ค์ .update()
ํธ์ถ์ ์ํด ์ ์ ํ ์์ ๊ธฐ๋ฅ์ผ๋ก ์
๋ฐ์ดํธ ๋์ง ์์ต๋๋ค .
๊ทธ๋ฌ๋ num_feature
๋ํ ๋ช
์์ ๊ฐ์ ์ ๋ฌํ๋ฉด ๋ถํ ์ค๋ฅ๊ฐ ํด๊ฒฐ๋ฉ๋๋ค.
booster_ = xgboost.Booster({'objective': 'reg:linear', 'num_feature': dtrain.num_col()})
cache=()
๊ฐ ๋น์ด ์๊ฑฐ๋ xgboost.Booster()
๊ฐ ๊ฒฝ๊ณ ๋ฅผ ๋ฐํํด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
'num_feature'
๋ params
์ธ์์ ๋ช
์์ ์ผ๋ก ์ค์ ๋์ด ์์ง ์์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ฌธ์ ์ ์์ธ์ด ๋ฌด์์ธ์ง ์์๋์ต๋๋ค. ๋๋ ๋ค์์ ํธ์ถํ์ฌ ๋น ๋ถ์คํฐ๋ฅผ ๋ง๋๋ ๊ฒ์ผ๋ก ๋ํ๋ฌ์ต๋๋ค.
GBTree ๋ถ์คํฐ๋ฅผ ๋ถ๋ถ์ ์ผ๋ก๋ง ์ด๊ธฐํํฉ๋๋ค. ํนํ ์ค์ํ ๋งค๊ฐ๋ณ์
num_feature
๊ธฐ๋ณธ์ ์ผ๋ก 0์ผ๋ก ์ค์
.update()
ํธ์ถ์ ์ํด ์ ์ ํ ์์ ๊ธฐ๋ฅ์ผ๋ก ์ ๋ฐ์ดํธ ๋์ง ์์ต๋๋ค .๊ทธ๋ฌ๋
num_feature
๋ํ ๋ช ์์ ๊ฐ์ ์ ๋ฌํ๋ฉด ๋ถํ ์ค๋ฅ๊ฐ ํด๊ฒฐ๋ฉ๋๋ค.cache=()
๊ฐ ๋น์ด ์๊ฑฐ๋xgboost.Booster()
๊ฐ ๊ฒฝ๊ณ ๋ฅผ ๋ฐํํด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.'num_feature'
๋params
์ธ์์ ๋ช ์์ ์ผ๋ก ์ค์ ๋์ด ์์ง ์์ต๋๋ค.