【简明教程】windows下xgboost安装到python

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a19990412/article/details/86633673

github clone

电脑上使用github

git clone https://github.com/dmlc/xgboost.git

会在对应的目录下,多出一个xgboost目录。

下载xgboost.dll

在这里插入图片描述

  • 将下载的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)

猜你喜欢

转载自blog.csdn.net/a19990412/article/details/86633673
今日推荐