dummyRegressor | R Documentation |
a method used for the train function in caret
dummyRegressor
An object of class list
of length 13.
# Split the data into training and testing sets
set.seed(2023)
index <- sample(1:nrow(iris), nrow(iris) * 0.8)
train_data <- iris[index,]
test_data <- iris[-index,]
ctrl1 <- caret::trainControl(method = "none")
# Train a dummy regressor with caret
reg_model <- caret::train(Sepal.Length ~ ., data = train_data,
method = dummyRegressor,
strategy = "median",
trControl = ctrl1)
y_hat <- predict(reg_model, test_data)
# Find mean squared error
mean((test_data$Sepal.Length-y_hat)^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.