View source: R/linear_reg-predict.R
predict.brulee_linear_reg | R Documentation |
brulee_linear_reg
Predict from a brulee_linear_reg
## S3 method for class 'brulee_linear_reg'
predict(object, new_data, type = NULL, epoch = NULL, ...)
object |
A |
new_data |
A data frame or matrix of new predictors. |
type |
A single character. The type of predictions to generate. Valid options are:
|
epoch |
An integer for the epoch to make predictions. If this value
is larger than the maximum number that was fit, a warning is issued and the
parameters from the last epoch are used. If left |
... |
Not used, but required for extensibility. |
A tibble of predictions. The number of rows in the tibble is guaranteed
to be the same as the number of rows in new_data
.
if (torch::torch_is_installed()) {
data(ames, package = "modeldata")
ames$Sale_Price <- log10(ames$Sale_Price)
set.seed(1)
in_train <- sample(1:nrow(ames), 2000)
ames_train <- ames[ in_train,]
ames_test <- ames[-in_train,]
# Using recipe
library(recipes)
ames_rec <-
recipe(Sale_Price ~ Longitude + Latitude, data = ames_train) %>%
step_normalize(all_numeric_predictors())
set.seed(2)
fit <- brulee_linear_reg(ames_rec, data = ames_train,
epochs = 50, batch_size = 32)
predict(fit, ames_test)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.