ubuntu 14.04配置XGboost

第一步:安装最新版的xgboost

打开终端输入:

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; make -j4

第二步:安装Python package

1、cd 到 python-package目录
sudo apt-get install python-setuptools
2、添加环境变量
在根目录下Crtl+h 显示隐藏文件 ~/.bashrc 
加入环境变量
export PYTHONPATH=~/xgboost/python-package

第三步:安装R package

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
make Rbuild
R CMD INSTALL xgboost_0.4-3.tar.gz
还可以用第二种方法:先安装R环境:sudo apt-get install r-base=core
在终端输入-R
> install.packages('xgboost')
> library(xgboost)
下面是简单的二分类的例子
第一步:准备训练数据 
cd xgboost/demo/binary_classification
python mapfeat.py
python mknfold.py agaricus.txt 1
会生成<span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6000003814697px;"> 'agaricus.txt.train' and 'agaricus.txt.test'</span>
<span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6000003814697px;">第二步:训练</span>
<span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6000003814697px;"></span><pre name="code" class="html" style="color: rgb(64, 64, 64);">cd xgboost/demo/binary_classification
../../xgboost mushroom.conf
会生成一个****.model的分类器
第三步:预测
<pre name="code" class="html" style="color: rgb(64, 64, 64);"><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6000003814697px;"></span><pre name="code" class="html" style="color: rgb(64, 64, 64);">cd xgboost/demo/binary_classification
../../xgboost mushroom.conf <span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: inherit; color: rgb(51, 51, 51); font-size: 14px; white-space: nowrap; background-color: transparent;">task=pred model_in=****.model</span>



 



 
 

 


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值