Questions tagged [tidymodels]

The tidymodels framework is a collection of R packages for modeling and machine learning using tidyverse principles.

Filter by
Sorted by
Tagged with
0 votes
2 answers
14 views

R Error: 'Error in step_select(): The column 'normalized_used_price' is missing from 'new_data'"

train data test set.seed(123) recipe_obj <- recipe(normalized_used_price ~ ., data = train) %>% step_select(-weight, -screen_size, -release_year, -normalized_new_price) %>% ...
Anderson Araujo's user avatar
0 votes
0 answers
29 views

Stuck with :For a classification model, the outcome should be a `factor`, not a `tbl_df`

Since days I get the above mentioned error. Here the output of my df: ` tibble [9,874,170 × 4] (S3: tbl_df/tbl/data.frame) $ series_id: chr [1:9874170] "08db4255286f" "08db4255286f&...
Peter Hahn's user avatar
2 votes
0 answers
22 views

Tidymodels xgboost using step_dummy(one_hot =T) - set mtry as proportion instead of range when creating custom grid and tuning with tune_race_anova

My train data has 32 columns, but since I am incorporating step_dummy(all_nomical_predictors), one_hot = T) in my recipe, I end up with more than 32 columns when modeling. Therefore, just running ...
Andy's user avatar
  • 129
0 votes
1 answer
34 views

How can I tune the `step_impute_knn` function from the recipe package?

I want to use the step_impute_knn function from the recipe package to impute missing values. This function uses the Gower distance as a distance metric, which is suitable when predictors are a mixture ...
GreenManXY's user avatar
3 votes
1 answer
44 views

Is there a way to to tune parameters inside a recipe workflow?

I'd like to use the step_impute_knn function from the recipe package to impute some missing values in my data. I've tested it with the default parameters (neighbours = 5, nthread = 1 and eps = 1e-08) ...
GreenManXY's user avatar
0 votes
0 answers
22 views

Type 3 Anova on parsnip models

Lets say I create an lm model with 2 predictors at least one which is categorical and there is also an interaction term involved. Now I would like to also get the significance level for the overall ...
Papa Analytica's user avatar
1 vote
2 answers
32 views

Applying functions designed to take base R model objects on Parsnip objects?

Most package authors design functions to take in the traditional R model objects like is there anyway to feed them a model object created by parsnip package and tidymodels? an example: model <- lm(...
Papa Analytica's user avatar
0 votes
1 answer
49 views

Optimizing parallelization in R using Tidymodels, Ranger and Workflowsets - slow

I am trying to run 35 different models (each with cvfold = 5 and grids of size 4 for tuning - so in essense actually 700 models) using Tidymodels' implementation of Ranger. I am using workflowsets to ...
Andy's user avatar
  • 129
0 votes
2 answers
30 views

Tidymodels How to extract tuned parameter with workflow map and collect_metrics?

Hello I noticed that collect_metrics function does not return the parameter of interest in this case Cost Complexity. I am not sure why this is the case. I created a small example with the iris ...
Victor Feagins's user avatar
4 votes
1 answer
154 views

Deploy tidymodel model to GCP using Docker and Vetiver

I'm trying to follow along to this Julia Silge MLOps video where she uses Vetiver and Tidymodels to deploy to AWS Sagemaker however after running up hundreds of dollars of bills on AWS :( I've moved ...
TheGoat's user avatar
  • 2,591
0 votes
1 answer
33 views

Create and plot ROC curve with tidymodels

Trying out a classification bagged tree in tidymodels and all is good until I get to creating and plotting the ROC curve. Then I get an # Error in 'roc_curve()': ! Can't rename variables in this ...
Lillian Welsh's user avatar
1 vote
0 answers
17 views

Using glmnet engine in tidymodels to fit models with percent data as response [migrated]

I am interested in using penalized regression (LASSO) with the glmnet engine in tidymodels to fit a model with a response variable that is continuous and bound between 0 and 1. I am familiar with how ...
Bryant's user avatar
  • 11
1 vote
1 answer
31 views

Use Purrr to filter and estimate the same model specification multiple times

I have a dataset that I want to use to estimate some linear models. The data can be replicated with the code below. set.seed(123) df <- tibble( location= c(rep("A",5),rep("B",...
Abraham Assefa's user avatar
3 votes
0 answers
135 views

Custom metrics that relies on additional features in training data

How can I implement a custom metric that relies on additional features in training data? Below is an example for within R Squared with additional code reproduce the core issue. The implementation uses ...
user2503795's user avatar
  • 4,045
0 votes
0 answers
23 views

mutate resampling (rset) object

I have created resampling folds using vfold_cv(). I need to adjust the $data dataframes within the $splits in each fold. After doing this, however, the object is no longer a rset object. How can I ...
Anna Jackson's user avatar
0 votes
1 answer
27 views

Manual feature selection as part of tuning process in tidymodels?

I would like to know whether certain features or a different way of coding a features improves the performance of my model. I am aware if this discussion on feature selection with tidymodels and the ...
user2503795's user avatar
  • 4,045
1 vote
1 answer
46 views

tidymodels: loss_accuracy provides no variable importance results

Using the iris dataset, a knn-classifier was tuned with iterative search for multiple classification. However, using loss accuracy in DALEX::model_parts() for variable importance, provides empty ...
bioblackgeorge's user avatar
0 votes
0 answers
72 views

XGBoost Bayesian Optimisation in tidymodels

I try to apply bayesian optimisation to a binary classification problem (XGBOOST) inside the tidymodels framework. Are there any flaws inside my code - the model has run since 2 days on a 72 CPU ...
arne maa's user avatar
0 votes
1 answer
39 views

Error fitting xgboost classification models with single predictor

I am trying to fit xgboost classification models with a single numeric predictor. There seems to be a bug that does not allow a feature matrix to be built when there is just one predictor variable. I ...
gfronk's user avatar
  • 1
0 votes
1 answer
63 views

'Invalid number of trees' error with XGBoost and tidymodels

I am trying to predict what a patients response to a treatment will be. I am an ethusiastic amateur when it comes to machine learning, but I can usually muddle my way through eventually. This one is ...
for_the_love_of_cod's user avatar
1 vote
1 answer
116 views

R kernelshap package with tidymodels with classification

Problem when trying to produce shap values for classification problem using tidymodels. hen i try to calculate shap values after training my model in tidymodels following steps on this site https://...
Jure Prusnik's user avatar
1 vote
2 answers
88 views

How to use broom::tidy for Tobit models?

Dear Stackoverflow community, I am struggling with using the tidy function from the broom package. I need this function in the context of a multiple imputation. You can see here a reprex example using ...
HuMaN90's user avatar
  • 13
0 votes
1 answer
55 views

Use multiple strata for initial_split?

I am working with biological data, genes, that have multiple characteristics which I want to have reflected properly in my training and test data. However, the initial_split function only accepts one ...
Martingales's user avatar
1 vote
1 answer
209 views

How to avoid inconsistent column name of predict() outputs?

Context: The tidymodels meta-package allows to streamline machine learning methods. I am trying to use it on my data and explore the model with DALEX package. Problem: When I use tune::last_fit() or ...
Paul's user avatar
  • 2,870
0 votes
1 answer
50 views

why tidymodels changes the value in data prep in R

Assume I have this data set. Please let me know if it is a duplicate but I am confused in this. library(tidymodels) mt <- mtcars[,c('mpg', 'hp', 'drat', 'am')] mt$hp <- as.character(mt$hp) mt$...
PKumar's user avatar
  • 11k
1 vote
1 answer
39 views

In R tidymodels how do I set the default level for evaluating a logistic model

I would like to tell yardstick that the default level for my logistic model is the second level. I know I can specify individual statistics with event_level = "second" but I would prefer to ...
itsMeInMiami's user avatar
  • 2,326
0 votes
1 answer
23 views

Compute Gini Index on a nested/rsplit object

I used rsample::bootstraps function to create a nested object just as follows : Sampled_Data=bootstraps(credit_data,times = 2,strata="Home",apparent = TRUE) What I get is as follows : ...
WalliYo_'s user avatar
  • 185
0 votes
1 answer
61 views

The meaning of an explanatory variable in computing accuracy of a prediction model (migrated to CrossValidated)

I am following the predictive modeling example found here, chapter 10. This piece of the code has capital_gain as the explanatory variable, but removing it or replacing it with another variable doesn'...
Gato's user avatar
  • 415
0 votes
0 answers
47 views

Library tidymodels Not Loading And Not reinstalling in R

I am unable to load tidy models library in R, I tried to re install it as well but that is not working as well. Can someone help me out. When I try to load library(tidymodels), I get this error: Error:...
user15473160's user avatar
0 votes
1 answer
68 views

Challenges using `tidymodels`, `parsnip`, and `workflows` for events/trials outcome

tidymodelRs out there! The Goal: reuse a recipe object for multiple modeling types (logistic, RF, etc). The Data: survey data that I have condensed to outcome_yes (numeric count of when something ...
kyle-G's user avatar
  • 51
3 votes
2 answers
61 views

Memory issues when obtaining TF-IDF data

Intro I am struggling with text classification of a big dataset of tweets and I would be thankful if someone could point me in the right direction. The big picture is that I need to train a classifier ...
George B. Y.'s user avatar
0 votes
1 answer
38 views

What is the correct syntax for specifying probability estimates in probably::cal_plot_breaks?

I have a data frame of predicted class probabilities and true label values and I cannot specify the class probabilities in probably::cal_plot_breaks in a way that does not generate either an error or ...
Alex Ondrus's user avatar
3 votes
1 answer
394 views

Balanced log loss function in yardstick

Can someone help me figure out how to create a balanced logarithmic loss function in yardstick for use in a tidymodels pipeline? I looked up the documentation on creating custom metrics and I was able ...
JaredS's user avatar
  • 242
0 votes
1 answer
24 views

How to extract the Wald p-value from a specific set of linear models with nested data

This is a 'many models' problem. I have a set of 16 binary candidate variables. I want to see the 'contribution' of each to a set of outcome variables (n=15), where the other covariates change ...
Claire Welsh's user avatar
-2 votes
1 answer
67 views

Conflicts or errors in the tune and tidymodels packages using information gain from the colino package or recipeselectors

This code was working until yesterday, when I uninstalled the recipeselectors and colino packages. I've looked everywhere and no one has reported a similar error. Link to download the database used: ...
Bruno Matos Porto's user avatar
1 vote
1 answer
54 views

Regression trees with tidymodels

When attempting to use Regression Trees, how do you determine if/ when to use tune_grid() versus fit_resamples()? I tried these two things: 1. using tune_grid tune_spec<- decision_tree(min_n= tune()...
Lillian Welsh's user avatar
0 votes
1 answer
52 views

creating a tuning grid for Regression Trees in R

Attempting my first randomForest model in R and am working through tuning hyperparameters. I created a spec first: tune_spec<- decision_tree() %>% set_engine("rpart") %>% set_mode(&...
Lillian Welsh's user avatar
1 vote
1 answer
86 views

Error in `purrr::map()`, unable to use step_select_*() from colino and workflow_map() together

Trying to use different step_select functions from the colino package before fitting multiple models with workflow_set(). Apparently using a step_select function as preprocessing in the recipe make it ...
Louie-david Desachy's user avatar
2 votes
0 answers
37 views

Prevent tidymodels from turning numeric to chr

Apologies if this has been asked before, but I was unable to find the corresponding info. I am using the recipe from tidymodels and trying to create a model (eventually). As I prepped my this is ...
Elliott Barinberg's user avatar
0 votes
1 answer
52 views

Problem when scoring new data -- tidymodels

I'm learning tidymodels. The following code runs nicely: library(tidyverse) library(tidymodels) # Draw a random sample of 2000 to try the models set.seed(1234) diamonds <- diamonds %>% ...
user23438's user avatar
  • 445
1 vote
1 answer
63 views

broom::augment errors with recipes::step_log

I am trying to use the tidymodels framework to predict outcome based on predictor. I want to use log(outcome) ~ predictor as my model, but outcome has zeroes. Therefore, I use recipes::step_log(...
joshbrows's user avatar
  • 159
0 votes
1 answer
61 views

Understanding why tune::last_fit metrics are different from summary()

Context: I try to evaluate a model, made using tune::last_fit() with an independent dataset. Problem: it seems that the metrics obtained with tune::collect_metrics() are different from the ones ...
Paul's user avatar
  • 2,870
0 votes
1 answer
33 views

G-mean custom metric Tidymodels R

I am trying to create a custom metric for evaluation using tidymodels in R. I want to compute the G-mean, which is the sqrt(sensitivity * specificity). I have tried to create the following function, ...
JorRu's user avatar
  • 3
0 votes
0 answers
43 views

Error in tidyLPA: "Error in UseMethod("get_data", x) : no applicable method for 'get_data' applied to an object of class "c('bestLPA', 'list')""

library(tidyLPA) prism2 <- prism %>% select(cars1, cars2, cars3, cars4, cars5, ihp1, ihp2, ihp3, ihp4, ihp5, oiq1, oiq2, oiq3, oiq4, oiq5, oiq6, oiq7, oiq8, sms1, sms2, sms3, sms4, ...
Ariana Johnson's user avatar
1 vote
1 answer
39 views

How to evaluate joint importance of two features in a model (random forest) using R package such as VIP or DALEXtra?

I know to use these packages (VIP etc) with tidymodels to evaluate individual feature contribution/importance for a model such as random forest. But I'd like to know to evaluate a combined or joint ...
Xiaokuan Wei's user avatar
0 votes
1 answer
37 views

Error when using step_dummy() to handle categorical variables with tidymodels, recipe, bayesian

I am trying to use the bayesian package to build a tidy bayesian model. I am mostly following the bayesian's get started vignette, although my specific use-case differs slightly in that I am trying to ...
leorar's user avatar
  • 43
1 vote
1 answer
174 views

log transform outcome variable in tidymodels workflow

I'm having a hard time getting a tidymodels workflow to make new predictions. Specifically, I want to log transform my outcome variable as part of the workflow, but when it comes time to predict new ...
JmPearl's user avatar
  • 11
0 votes
1 answer
67 views

step_poly error in tidymodels: "'degree' must be less than number of unique points"

I have seen several questions + answers for similar posts in SO (ex. 1, ex. 2, ex. 3), but none seem to really address the problem in the context of tidymodels. I am trying to use a second-order ...
codeweird's user avatar
  • 145
0 votes
1 answer
64 views

How to cherry pick tuned parameters after workflow_map

I've tuned succesfully several models using {tidymodels} and {workflow_set}. However, when testing the validation dataset with tune::last_fit(), the parameters obtained by tune::select_best don't ...
jpm92's user avatar
  • 143
2 votes
1 answer
69 views

logistic_reg() estimates in tidymodels interpretation seem to be predicting incorrect class as positive outcome

I am using tidymodels to develop a logistic regression using the Palmer's Penguins dataset. I believe that female should be the reference class since it is the first level of my outcome variable, and ...
Dominic Foy's user avatar

1
2 3 4 5
13