importxgboostasxgb# read in datadtrain=xgb.DMatrix('demo/data/agaricus.txt.train')dtest=xgb.DMatrix('demo/data/agaricus.txt.test')# specify parameters via mapparam={'max_depth':2,'eta':1,'silent':1,'objective':'binary:logistic'}num_round=2bst=xgb.train(param,dtrain,num_round)# make predictionpreds=bst.predict(dtest)
安装XGBoost-R
安装XGBoost包:
12
>install.packages('xgboost')>library(xgboost)
测试:
123456789
# load datadata(agaricus.train,package='xgboost')data(agaricus.test,package='xgboost')train<-agaricus.traintest<-agaricus.test# fit modelbst<-xgboost(data=train$data,label=train$label,max.depth=2,eta=1,nround=2,nthread=2,objective="binary:logistic")# predictpred<-predict(bst,test$data)