Skip to content

Commit

Permalink
Set nthread = 1 in xgb.DMatrix() in vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
mayer79 committed Nov 10, 2023
1 parent 5836aca commit c8e67ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion vignettes/basic_use.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ diamonds[, ord] <- lapply(diamonds[, ord], factor, ordered = FALSE)
# Fit XGBoost model
x <- c("carat", "clarity", "cut", "color")
dtrain <- xgb.DMatrix(data.matrix(diamonds[x]), label = diamonds$price)
dtrain <- xgb.DMatrix(data.matrix(diamonds[x]), label = diamonds$price, nthread = 1)
fit <- xgb.train(
params = list(learning_rate = 0.1, nthread = 1), data = dtrain, nrounds = 65
)
Expand Down
8 changes: 4 additions & 4 deletions vignettes/geographic.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ y_train <- log(miami$SALE_PRC[ix])
y_valid <- log(miami$SALE_PRC[-ix])
# Fit XGBoost model with early stopping
dtrain <- xgb.DMatrix(X_train, label = y_train)
dvalid <- xgb.DMatrix(X_valid, label = y_valid)
dtrain <- xgb.DMatrix(X_train, label = y_train, nthread = 1)
dvalid <- xgb.DMatrix(X_valid, label = y_valid, nthread = 1)
params <- list(
learning_rate = 0.2, objective = "reg:squarederror", max_depth = 5, nthread = 1
Expand Down Expand Up @@ -127,8 +127,8 @@ x2 <- c(x, more_geo)
X_train2 <- data.matrix(miami[ix, x2])
X_valid2 <- data.matrix(miami[-ix, x2])
dtrain2 <- xgb.DMatrix(X_train2, label = y_train)
dvalid2 <- xgb.DMatrix(X_valid2, label = y_valid)
dtrain2 <- xgb.DMatrix(X_train2, label = y_train, nthread = 1)
dvalid2 <- xgb.DMatrix(X_valid2, label = y_valid, nthread = 1)
# Build interaction constraint vector
ic <- c(
Expand Down
4 changes: 2 additions & 2 deletions vignettes/multiple_output.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ library(xgboost)
params <- list(objective = "multi:softprob", num_class = 3, nthread = 1)
X_pred <- data.matrix(iris[, -5])
dtrain <- xgb.DMatrix(X_pred, label = as.integer(iris[, 5]) - 1)
dtrain <- xgb.DMatrix(X_pred, label = as.integer(iris[, 5]) - 1, nthread = 1)
fit <- xgb.train(params = params, data = dtrain, nrounds = 50)
# Create "mshapviz" object (logit scale)
Expand Down Expand Up @@ -125,7 +125,7 @@ library(patchwork)
library(xgboost)
X_pred <- data.matrix(iris[, -1])
dtrain <- xgb.DMatrix(X_pred, label = iris[, 1])
dtrain <- xgb.DMatrix(X_pred, label = iris[, 1], nthread = 1)
fit_xgb <- xgb.train(params = list(nthread = 1), data = dtrain, nrounds = 50)
# Create "mshapviz" object
Expand Down

0 comments on commit c8e67ad

Please sign in to comment.