Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildExplainer error when running your example #16

Open
zk117 opened this issue Jan 31, 2018 · 5 comments
Open

buildExplainer error when running your example #16

zk117 opened this issue Jan 31, 2018 · 5 comments

Comments

@zk117
Copy link

zk117 commented Jan 31, 2018

library(xgboost)

library(xgboostExplainer)

set.seed(123)

data(agaricus.train, package='xgboost')

X = as.matrix(agaricus.train$data)

y = agaricus.train$label

train_idx = 1:5000

train.data = X[train_idx,]

test.data = X[-train_idx,]

xgb.train.data <- xgb.DMatrix(train.data, label = y[train_idx])

xgb.test.data <- xgb.DMatrix(test.data)

param <- list(objective = "binary:logistic")

xgb.model <- xgboost(param =param, data = xgb.train.data, nrounds=3)
[1] train-error:0.000000
[2] train-error:0.000000
[3] train-error:0.000000

col_names = colnames(X)

pred.train = predict(xgb.model,X)

nodes.train = predict(xgb.model,X,predleaf =TRUE)

trees = xgb.model.dt.tree(col_names, model = xgb.model)

The XGBoost Explainer

explainer = buildExplainer(xgb.model,xgb.train.data, type="binary", base_score = 0.5, n_first_tree = xgb.model$best_ntr .... [TRUNCATED]

Creating the trees of the xgboost model...Error in parse(text = paste(new_par, "<-", pars[[pars_par]])) :
:2:0: unexpected end of input
1: trees <-
^
In addition: Warning message:
'n_first_tree' is deprecated.
Use 'trees' instead.
See help("Deprecated") and help("xgboost-deprecated").
Called from: parse(text = paste(new_par, "<-", pars[[pars_par]]))

@amir-ghasemi
Copy link

Having the same issue with xgboost 0.6.4.6

@skamkar
Copy link

skamkar commented Mar 10, 2018

As the error states, 'n_first_tree' has been deprecated by 'trees'. A simple input variable name substitution will resolve this discrepancy.

See here: https://github.com/AppliedDataSciencePartners/xgboostExplainer/blob/master/R/buildExplainer.R#L61

@LegiSam
Copy link

LegiSam commented May 12, 2018

I also faced the same problem when I was using the Github version. To overcome this, I download the stable version (0.6.4.1) on CRAN and it worked without any problems.

@PirateGrunt
Copy link

I think the issue is to do with how the example code is written. It references a property of the xgboost model object best_ntreelimit which is only available when the early_stopping_rounds argument has been set in the call to xgboost().

@Reindert94
Copy link

I faced the same problem when upgrading to xgboost version (0.71.1). Downgrading again to 0.6.4.1 (as LegiSam describes above) does the trick.

PirateGrunt added a commit to PirateGrunt/xgboostExplainer that referenced this issue May 22, 2018
@PirateGrunt PirateGrunt mentioned this issue May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants