Merge branch 'unity'
Conflicts: .gitignore R-package/src/xgboost_R.cpp src/gbm/gblinear-inl.hpp tools/xgcombine_buffer.cpp
This commit is contained in:
@@ -32,6 +32,8 @@ This is a list of short codes introducing different functionalities of xgboost a
|
||||
[python](guide-python/cross_validation.py)
|
||||
[R](../R-package/demo/cross_validation.R)
|
||||
[Julia](https://github.com/antinucleon/XGBoost.jl/blob/master/demo/cross_validation.jl)
|
||||
* Predicting leaf indices
|
||||
[python](guide-python/predict_leaf_indices.py)
|
||||
|
||||
Basic Examples by Tasks
|
||||
====
|
||||
|
||||
@@ -6,3 +6,4 @@ XGBoost Python Feature Walkthrough
|
||||
* [Predicting using first n trees](predict_first_ntree.py)
|
||||
* [Generalized Linear Model](generalized_linear_model.py)
|
||||
* [Cross validation](cross_validation.py)
|
||||
* [Predicting leaf indices](predict_leaf_indices.py)
|
||||
|
||||
22
demo/guide-python/predict_leaf_indices.py
Executable file
22
demo/guide-python/predict_leaf_indices.py
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/python
|
||||
import sys
|
||||
import numpy as np
|
||||
sys.path.append('../../wrapper')
|
||||
import xgboost as xgb
|
||||
|
||||
### load data in do training
|
||||
dtrain = xgb.DMatrix('../data/agaricus.txt.train')
|
||||
dtest = xgb.DMatrix('../data/agaricus.txt.test')
|
||||
param = {'max_depth':2, 'eta':1, 'silent':1, 'objective':'binary:logistic' }
|
||||
watchlist = [(dtest,'eval'), (dtrain,'train')]
|
||||
num_round = 3
|
||||
bst = xgb.train(param, dtrain, num_round, watchlist)
|
||||
|
||||
print ('start testing predict the leaf indices')
|
||||
### predict using first 2 tree
|
||||
leafindex = bst.predict(dtest, ntree_limit=2, pred_leaf = True)
|
||||
print leafindex.shape
|
||||
print leafindex
|
||||
### predict all trees
|
||||
leafindex = bst.predict(dtest, pred_leaf = True)
|
||||
print leafindex.shape
|
||||
@@ -4,4 +4,5 @@ python custom_objective.py
|
||||
python boost_from_prediction.py
|
||||
python generalized_linear_model.py
|
||||
python cross_validation.py
|
||||
rm -rf *~ *.model *.buffer
|
||||
python predict_leaf_indices.py
|
||||
rm -rf *~ *.model *.buffer
|
||||
|
||||
Reference in New Issue
Block a user