Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error loading saved ranger model after updating mlr3verse package #1248

Open
Schwarzeneggerjune opened this issue Jan 23, 2025 · 4 comments
Open

Comments

@Schwarzeneggerjune
Copy link

Description:
I encountered an issue after updating the mlr3verse package in R. I created a binary classification model using ranger with mlr3verse version 0.2.8 in R 4.3.0 and saved the model as an .rds file for future use. However, after updating one of the packages within mlr3verse, I can no longer load the saved model file. The error message is as follows:
LearnerClassifRanger:classif.ranger

  • Model: ranger
    Error in private$.get_values() : attempt to apply non-function
    I attempted to resolve the issue by reinstalling the previous version of mlr3verse (0.2.8), but the problem persists. I suspect that the update might have caused a compatibility issue with the saved model.
    Steps to Reproduce:
    Create a binary classification model using ranger with mlr3verse version 0.2.8.
    Save the model as an .rds file using saveRDS().
    Update one of the packages within mlr3verse.
    Load the saved model using readRDS() and attempt to use it.
    Expected behavior:
    The model should load correctly and be usable as before the update.
    Actual behavior:
    The model fails to load with the error message mentioned above.
    System Information:
    R version: 4.3.0
    mlr3verse version: 0.2.8 (initially) and updated versions
    Platform: [Your operating system, e.g., Windows 10, macOS Monterey]
    Additional context:
    I have tried the following steps to resolve the issue:
    Reinstalling the previous version of mlr3verse (0.2.8).
    Checking for any changes in the ranger package dependencies.
    However, none of these steps have resolved the issue. I would appreciate any guidance on how to resolve this compatibility problem or if there is a way to convert the saved model to a compatible format.
    Thank you for your assistance!
@Schwarzeneggerjune
Copy link
Author

the model was stored at https://github.com/Schwarzeneggerjune/ColonTrack

@be-marc
Copy link
Member

be-marc commented Jan 23, 2025

@Schwarzeneggerjune
Copy link
Author

Can you try https://mlr-org.com/faq.html#old-model-broken?

Yes,actually, I have tried this method. My model was built based on mlr3 0.16.1, I tried to re-install mlr3 0.16.1, but it didn't work. And then I built a new model with the lastest mlr3 and run the following code.
learner = lrn("classif.rpart")
learner_old = readRDS("learner.rds")
learner$state = learner_old$state
I used the new learner to predict, there is still error,
learner$predict(task$new)
error:Setting row roles 'test'/'holdout' is no longer possible.

@Schwarzeneggerjune
Copy link
Author

Can you try https://mlr-org.com/faq.html#old-model-broken?

I have fixed this issue. The error was generated from the R6 class ParaSet, and this class was defined in package 'paradox'. So actually the error is not due to the incorrect version of mlr3, but rather due to the incorrect version of paradox. After installing the old version of paradox, the model ran successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants