版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a19990412/article/details/86633673
文章目录
github clone
电脑上使用github
git clone https://github.com/dmlc/xgboost.git
会在对应的目录下,多出一个xgboost目录。
下载xgboost.dll
- 访问 http://www.picnet.com.au/blogs/guido/2016/09/22/xgboost-windows-x64-binaries-for-download/
- 在下面选一个,如果有cuda的话,就选GPU版本的,否则就选Not GPU
- 将下载的
xgboost.dll
文件放到git clone下来的python-package\xgboost
文件夹中
编译
进入到git clone下来的python-package
文件夹中,进入命令行
输入:Python setup.py install
检测
D:\>python
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xgboost
D:\SoftWare\Python\lib\site-packages\sklearn\externals\joblib\externals\cloudpickle\cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
>>> xr = xgboost.XGBRegressor()
>>> import numpy as np
>>> X = np.array([[1, 2, 3], [4, 5, 6]])
>>> y = np.array([1, 2])
>>> xr.fit(X, y)
XGBRegressor(base_score=0.5, booster='gbtree', colsample_bylevel=1,
colsample_bytree=1, gamma=0, importance_type='gain',
learning_rate=0.1, max_delta_step=0, max_depth=3,
min_child_weight=1, missing=None, n_estimators=100, n_jobs=1,
nthread=None, objective='reg:linear', random_state=0, reg_alpha=0,
reg_lambda=1, scale_pos_weight=1, seed=None, silent=True,
subsample=1)
>>> X_t = np.array([[1, 2, 3],])
>>> xr.predict(X_t)
array([0.9978384], dtype=float32)