library(tidymodels)
library(ordered)
library(future)
plan("multisession")
set.seed(1215)
ames_split <-
ames |>
select(Latitude, Sale_Price) |>
initial_split(strata = Sale_Price)
ames_train <- training(ames_split)
ames_test <- testing(ames_split)
ames_rs <- vfold_cv(ames_train, strata = Sale_Price)
qnt_lvls <- c(0.05, 0.25, 0.5, 0.75, 0.95)
nnet_spec <-
mlp(hidden_units = tune(), penalty = tune(), epochs = 10) |>
set_mode("quantile regression", quantile_levels = qnt_lvls) |>
set_engine("qrnn", method = "adam")
nnet_rec <- recipe(Sale_Price ~ ., data = ames_train) |>
step_normalize(all_predictors())
nnet_wflow <- workflow(nnet_rec, nnet_spec)
qnt_set <- metric_set(weighted_interval_score)
# works with no metric set input
set.seed(971)
nnet_res <-
nnet_wflow |>
tune_grid(
resamples = ames_rs,
grid = 3
# metrics = qnt_set
)
# whomp whomp
set.seed(971)
nnet_res <-
nnet_wflow |>
tune_grid(
resamples = ames_rs,
grid = 3,
metrics = qnt_set
)
#> Error in `tune_grid()`:
#> ! The `metrics` argument should be the results of
#> `yardstick::metric_set()`.
Created on 2026-04-23 with reprex v2.1.1
Created on 2026-04-23 with reprex v2.1.1