Skip to content

Commit

Permalink
python package refactor into python-package
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Jul 31, 2015
1 parent f6fed76 commit c2fec29
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 678 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Rcheck:

# lint requires dmlc to be in current folder
lint:
dmlc-core/scripts/lint.py xgboost $(LINT_LANG) src wrapper R-package
dmlc-core/scripts/lint.py xgboost $(LINT_LANG) src wrapper R-package python-package

clean:
$(RM) -rf $(OBJ) $(BIN) $(MPIBIN) $(MPIOBJ) $(SLIB) *.o */*.o */*/*.o *~ */*~ */*/*~
Expand Down
3 changes: 2 additions & 1 deletion demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.libsvm
*.libsvm
*.pkl
18 changes: 9 additions & 9 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
XGBoost Examples
====
This folder contains all the code examples using xgboost.
This folder contains all the code examples using xgboost.

* Contribution of examples, benchmarks is more than welcome!
* If you like to share how you use xgboost to solve your problem, send a pull request:)

Features Walkthrough
====
This is a list of short codes introducing different functionalities of xgboost and its wrapper.
* Basic walkthrough of wrappers
This is a list of short codes introducing different functionalities of xgboost packages.
* Basic walkthrough of packages
[python](guide-python/basic_walkthrough.py)
[R](../R-package/demo/basic_walkthrough.R)
[Julia](https://github.com/antinucleon/XGBoost.jl/blob/master/demo/basic_walkthrough.jl)
Expand All @@ -20,18 +20,18 @@ This is a list of short codes introducing different functionalities of xgboost a
[python](guide-python/boost_from_prediction.py)
[R](../R-package/demo/boost_from_prediction.R)
[Julia](https://github.com/antinucleon/XGBoost.jl/blob/master/demo/boost_from_prediction.jl)
* Predicting using first n trees
* Predicting using first n trees
[python](guide-python/predict_first_ntree.py)
[R](../R-package/demo/boost_from_prediction.R)
[Julia](https://github.com/antinucleon/XGBoost.jl/blob/master/demo/boost_from_prediction.jl)
[Julia](https://github.com/antinucleon/XGBoost.jl/blob/master/demo/boost_from_prediction.jl)
* Generalized Linear Model
[python](guide-python/generalized_linear_model.py)
[R](../R-package/demo/generalized_linear_model.R)
[Julia](https://github.com/antinucleon/XGBoost.jl/blob/master/demo/generalized_linear_model.jl)
[Julia](https://github.com/antinucleon/XGBoost.jl/blob/master/demo/generalized_linear_model.jl)
* Cross validation
[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)
[Julia](https://github.com/antinucleon/XGBoost.jl/blob/master/demo/cross_validation.jl)
* Predicting leaf indices
[python](guide-python/predict_leaf_indices.py)
[R](../R-package/demo/predict_leaf_indices.R)
Expand All @@ -48,5 +48,5 @@ However, the parameter settings can be applied to all versions
Benchmarks
====
* [Starter script for Kaggle Higgs Boson](kaggle-higgs)
* [Kaggle Tradeshift winning solution by daxiongshu](https://github.com/daxiongshu/kaggle-tradeshift-winning-solution)
* [Kaggle Tradeshift winning solution by daxiongshu](https://github.com/daxiongshu/kaggle-tradeshift-winning-solution)

10 changes: 0 additions & 10 deletions demo/guide-python/sklearn_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,3 @@
clf.fit(X_train, y_train, early_stopping_rounds=10, eval_metric="auc",
eval_set=[(X_test, y_test)])

# Custom evaluation function
from sklearn.metrics import log_loss


def log_loss_eval(y_pred, y_true):
return "log-loss", log_loss(y_true.get_label(), y_pred)


clf.fit(X_train, y_train, early_stopping_rounds=10, eval_metric=log_loss_eval,
eval_set=[(X_test, y_test)])
2 changes: 1 addition & 1 deletion doc/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A [walk through python example](https://github.com/tqchen/xgboost/blob/master/de
=
#### Install

To install XGBoost, you need to run `make` in the root directory of the project and then in the `wrappers` directory run
To install XGBoost, you need to run `make` in the root directory of the project and then in the `python-package` directory run

```shell
python setup.py install
Expand Down
3 changes: 3 additions & 0 deletions python-package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
dist
*.egg*
7 changes: 7 additions & 0 deletions python-package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
XGBoost Python Package
======================
* To make the python module, type ```./build.sh``` in the root directory of project
* Make sure you have [setuptools](https://pypi.python.org/pypi/setuptools)
* Install with `python setup.py install` from this directory.
* Refer also to the walk through example in [demo folder](../demo/guide-python)
* **NOTE**: if you want to run XGBoost process in parallel using the fork backend for joblib/multiprocessing, you must build XGBoost without support for OpenMP by `make no_omp=1`. Otherwise, use the forkserver (in Python 3.4) or spawn backend. See the sklearn_parallel.py demo.
21 changes: 21 additions & 0 deletions python-package/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# pylint: disable=invalid-name
"""Setup xgboost package."""
from __future__ import absolute_import
import sys
from setuptools import setup
sys.path.insert(0, '.')
import xgboost

LIB_PATH = xgboost.core.find_lib_path()

setup(name='xgboost',
version=xgboost.__version__,
description=xgboost.__doc__,
install_requires=[
'numpy',
'scipy',
],
zip_safe=False,
packages=['xgboost'],
data_files=[('xgboost', [LIB_PATH[0]])],
url='https://github.com/dmlc/xgboost')
Loading

0 comments on commit c2fec29

Please sign in to comment.