predict.eztune {EZtune}R Documentation

Prediction function for EZtune

Description

predict.eztune Computes predictions for a validation dataset.

Usage

## S3 method for class 'eztune'
predict(object, newdata, ...)

Arguments

object

An object of class "eztune".

newdata

Matrix or data frame containing the test or validation dataset.

...

Additional parameters to pass to predict.

Value

Function returns a vector of predictions if the response is continuous. If the response is binary, a data.frame with the predicted response and the probabilities of each response type is returned.

Examples

library(EZtune)
data(lichen)
data(lichenTest)

y <- lichen[, 2]
x <- lichen[, 9:41]

# Optimize an SVM classification model using the default settings
mod1 <- eztune(x, y)

# Obtain predictions using the lichenTest dataset and compute classification
# error
pred <- predict(mod1, lichenTest)
mean(pred$predictions == as.factor(lichenTest$LobaOreg))

# Optimize an SVM regression model using the default settings
library(mlbench)
library(dplyr)
library(yardstick)
data(BostonHousing2)
bh <- mutate(BostonHousing2, lcrim = log(crim)) %>%
  select(-town, -medv, -crim)
x <- bh[, c(1:3, 5:17)]
y <- bh[, 4]
mod2 <- eztune(x, y)

# Obtain predictions from the original data and compute the rmse
pred <- predict(mod2, x)
rmse_vec(pred, y)

[Package EZtune version 3.1.1 Index]