train_rf: Train Random Forest model

View source: R/train_MLmodels.R

train_rfR Documentation

Train Random Forest model

Description

Trains a Random Forest regression model.

Usage

train_rf(data, formula, ntree = 500, seed = 123)

Arguments

data

A data frame containing the training data.

formula

A formula describing the model structure.

ntree

Number of trees to grow (default 500).

seed

Random seed for reproducibility (default 123).

Value

A trained randomForest model object.

Examples


library(randomForest)
data(mtcars)
rf_model <- train_rf(mtcars, mpg ~ cyl + hp + wt, ntree = 100)
print(rf_model)


mlspatial documentation built on Aug. 27, 2025, 1:09 a.m.