I installed xgboost on windows os, following the resources above, which is still not available in pip. However, I tried using the following function code to configure cv parameters:
#Import libraries: import pandas as pd import numpy as np import xgboost as xgb from xgboost.sklearn import XGBClassifier from sklearn import cross_validation, metrics
A function is created to obtain the optimal parameters and display the output in a visual form.
def modelfit(alg, dtrain, predictors,useTrainCV=True, cv_folds=5, early_stopping_rounds=50): if useTrainCV: xgb_param = alg.get_xgb_params() xgtrain = xgb.DMatrix(dtrain[predictors].values, label=dtrain[target].values) cvresult = xgb.cv(xgb_param, xgtrain, num_boost_round=alg.get_params()['n_estimators'], nfold=cv_folds, metrics='auc', early_stopping_rounds=early_stopping_rounds, show_progress=False) alg.set_params(n_estimators=cvresult.shape[0])
Now, when the function is called to get the optimal parameters:
#Choose all predictors except target & IDcols predictors = [x for x in train.columns if x not in [target]] xgb = XGBClassifier( learning_rate =0.1, n_estimators=1000, max_depth=5, min_child_weight=1, gamma=0, subsample=0.7, colsample_bytree=0.7, objective= 'binary:logistic', nthread=4, scale_pos_weight=1, seed=198) modelfit(xgb, train, predictors)
Although a function importance chart is displayed, information about the parameters in the red box at the top of the chart is missing:
Consulted with people using linux / mac and installed xgboost. They receive the above information. I was wondering if this is related to a specific implementation, I build and install in windows. And how can I get the parameter information displayed above the chart. At the moment, I am getting a diagram, not a red frame and the information inside it. Thanks.