Skip to content

predict() does not work if fitted workflow object has been saved as rds.  #45

Closed
@fderyckel

Description

@fderyckel

I have used this page for help:
https://workflows.tidymodels.org/reference/predict-workflow.html

the workflow is a nlp task using lasso and textrecipes.

I fitted a workflow object using fit(wf, train_data)
Then I use the workflow object with predict(wf, newdata). no error. It works as expected.

If I saved the workflow object using write_rds(). Close the session, clean all objects, restart r.
I read the workflow object using read_rds(wf.rds), then apply predict to that object. It gives me error.

model_lasso_enhanced <- read_rds("disaster_tweets/models/model_lasso_enhanced.rds")
yo <- predict(model_lasso_enhanced, new_data = test, type = "prob")
Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "c('lognet', 'glmnet')"
class(model_lasso_enhanced)
[1] "workflow"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions