tidymodels / parsnip

A tidy unified interface to models
https://parsnip.tidymodels.org
Other
599 stars 89 forks source link

Issues with extension packages #1079

Closed marcelglueck closed 8 months ago

marcelglueck commented 8 months ago

The problem

It seems that parsnip v1.2.0 has some major issues when trying to incorporate parsnip extension packages. (Please do not wonder about the tune() functions, this is part of the mrIML package). As this is a very generic issue, I opted to not include a reproducible example. I hope this is fine.

Example

bnn_model_specs <- bag_mlp(penalty = tune(), hidden_units = tune(), epochs = tune()) %>%
  set_engine("nnet") %>%
  set_mode("regression")

Running this model results in

in add_model(., Model) : 
  ! parsnip could not locate an implementation for `bag_mlp` regression model specifications using the `nnet` engine.
ℹ The parsnip extension package baguette implements support for this specification.
ℹ Please install (if needed) and load to continue.

However, baguette is already installed and loaded.

The same is for neural networks with h2o:

h2o::h2o.init()
mlnn_model_specs <- mlp(
  hidden_units = tune(),
  penalty = tune(),
  dropout = tune(),
  epochs = tune(),
  learn_rate = tune(),
) %>%
  set_engine("h2o") %>%
  set_mode("regression")

results in

in add_model(., Model) : 
  ! parsnip could not locate an implementation for `mlp` regression model specifications using the `h2o` engine.
ℹ The parsnip extension package agua implements support for this specification.
ℹ Please install (if needed) and load to continue.

Also in this case, agua is installed and loaded.

I am clueless on how to proceed from here. Thank you for your assistance

simonpcouch commented 8 months ago

Thanks for the issue!

Can you please provide a minimal reprex (reproducible example)? A reprex will help me troubleshoot and fix your issue more quickly.🙂

marcelglueck commented 8 months ago

Thank you for your swift reply. Here is the code.

if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
devtools::install_github('nfj1380/mrIML')

library(mrIML); library(vip);
library(tidymodels); library(randomForest); library(caret); library(gbm);
library(tidyverse); library(parallel); library(doParallel); library(themis); 
library(viridis); library(janitor); library(hrbrthemes); library(xgboost); 
library(vegan);library(flashlight); library(ggrepel); library(iml); library(plyr); 
library(future.apply); library(here); library(randomForest); library(RColorBrewer);
library(tidytext); library(baguette); library(cowplot); library(Hmisc);
library(ggpubr); library(lme4); library(multilevelmod); library(nnet); library(brulee);
library(h2o)

repro_env <- structure(list(SMI_mean_31217_6 = c(0.543076923076923, 0.528538461538462, 
0.501, 0.583923076923077, 0.415538461538462, 0.525769230769231, 
0.269538461538462, 0.205076923076923, 0.475923076923077, 0.660153846153846
), precipitation_radolan_rain_days_RR20_sd_19007_20240102 = c(2.4338877385388, 
2.02366946294055, 3.34236870668521, 2.18653890451379, 2.8900486072696, 
2.54109087935533, 2.21036519283902, 2.58751581545661, 2.13139793160666, 
2.08623607302265), SM_10_sd_19007_20240102 = c(3.79258728922163, 
2.96689433228755, 4.44609265901482, 7.81303574184359, 3.42502828381447, 
3.66011373449192, 2.99499301492159, 2.83111447753868, 6.57462858764066, 
5.02874069720442), Ta_10_sd_19007_20240102 = c(0.664172951833536, 
0.583166269195392, 0.467109090432081, 0.44906297956133, 0.453293900842568, 
0.467197329794673, 0.534911356007194, 0.582024788773874, 0.564143083128579, 
0.494169776920269)), class = "data.frame", row.names = c(NA, 
-10L))

repro_gen <- structure(list(all_count_mean = c(266.878982567545, 267.734934422809, 
262.360365639283, 259.418687726672, 263.710664761105, 264.178315722676, 
260.510179927927, 235.273410585656, 254.614593658035, 262.774254090415
), all_count_sd = c(31.0201987859519, 26.5466391249883, 31.3052984942398, 
30.9080211142491, 32.7514785418911, 31.1530217915232, 31.3710921116059, 
35.7481735407123, 39.7417686008089, 31.7002157380193), var_count_max = c(33, 
31, 33, 30, 34, 37, 29, 19, 26, 28), var_count_mean = c(0.0695955024131745, 
0.0776499530831004, 0.0790185522234207, 0.0824291682690803, 0.0875562912304877, 
0.0845768078030163, 0.0775513842296716, 0.143170327949532, 0.162679257249568, 
0.0796280399896566)), class = "data.frame", row.names = c(NA, 
-10L))

bnn_model_specs <- bag_mlp(penalty = tune(), hidden_units = tune(), epochs = tune()) %>%
  set_engine("nnet") %>%
  set_mode("regression")

yhats <- mrIMLpredicts(
  X = repro_env,
  Y = repro_gen,
  Model = bnn_model_specs,
  balance_data = "no",
  mode = "regression",
  tune_grid_size = 50,
  seed = 15119167,
  k = 5)
simonpcouch commented 8 months ago

Can you please provide output from the reprex package specifically? This way I can see what error messages you see and when and be sure that I can reproduce the environment that you see them in. Also, this code sample loads many, many packages; could you pare those down to only the packages and code that are needed?

marcelglueck commented 8 months ago

In preparing the reproducible example, I realized that this issue is caused by mrIML and not parsnip. Thank you for your assistance though.

simonpcouch commented 8 months ago

You're welcome!

github-actions[bot] commented 8 months ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.