View source: R/train_MLmodels.R
train_xgb | R Documentation |
Train XGBoost model
train_xgb(data, formula, nrounds = 100, max_depth = 4, eta = 0.1)
data |
A data frame with the training data. |
formula |
A formula defining the model structure. |
nrounds |
Number of boosting iterations. |
max_depth |
Maximum tree depth. |
eta |
Learning rate. |
Trains an XGBoost regression model.
A trained xgboost model object.
# Load required package
library(xgboost)
# Use built-in dataset
data(mtcars)
# Define regression formula
xgb_formula <- mpg ~ cyl + disp + hp + wt
# Train XGBoost model
xgb_model <- train_xgb(data = mtcars, formula = xgb_formula, nrounds = 50)
# Print model summary
print(xgb_model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.