predict.eztune: Prediction function for EZtune

Description Usage Arguments Value Examples

View source: R/predict_eztune.R

Description

predict.eztune Computes predictions for a validation dataset.

Usage

1
2
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)

EZtune documentation built on Dec. 11, 2021, 9:33 a.m.