You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issues instantiating/running models from flows #718
I am trying to use a flow to instantiate a sklearn model that can then be run on a task. From the documentation it seems like this should be possible in several different ways, but haven't had any success so far trying to get a model from a flow with flow_to_model or from a setup with initialize_model.
Running a flow directly on a task doesn't seem to work either.
Do you have any suggestions?
Sorry for the delay.
To reproduce the issue, please let us know which flow and/or setup you are working with.
That said, running a flow on a task is easiest done in the following way (e.g. task 3 and flow 7684):
importopenmltask=openml.tasks.get_task(3)
flow=openml.flows.get_flow(7684, reinstantiate=True) # Necessary otherwise no model is made.run=openml.runs.run_flow_on_task(flow, task)
Note the one line in the middle, where the model is reinstantiated after downloading the flow. I think it's fair to say that we should check for this automatically in the run_flow_on_task method.
But maybe, the required sklearn version depends on which version was used in the original flow... When I try a different flow, the error mentions a different sklearn version.
Yes, that is the case. The flows require a specific scikit-learn version to ensure reproducibility. I don't believe there currently is a way to automatically create a new flow for your scikit-learn version based on a flow-id and your current environment (or find one on the server that matches). I can understand this would be a desirable feature, which for pure-scikit-learn based flows should be feasible.
A little disclaimer, I was not involved at the time this flow (6970) was created or the related study (study14) was done. With that said, it looks like the flow you are trying to deserialize (6970) in particular also relies on non-scikit-learn components (openmlstudy14.preprocessing.ConditionalImputer). I don't currently know the status of reproducing that scenario, perhaps @mfeurer knows. I image you need to make sure the original source code can be found (https://github.com/openml/Study-14), which @janvanrijn should be more familiar with.
@PGijsbers Thanks for all the replies! It would be great to do the instantiation automatically for run_flow_on_task. I couldn't find that in the documentation and the error message is not very helpful. Maybe either you or @hp2500 can just add this to the error message for now.
I don't think instantiating Study-14 pipelines should be a high priority (there is no setup.py). We were actually more interested in getting the parameters of the last pipeline step. To do that, we could in principle just use mocking to replace the ContitionalImputer just so we can call pipeline[-1].get_params(). But maybe that's to specialized.
More generally I think it would be good to optionally disable the version check if the libraries are available.
I'll make the change to automatically reinstantiate the model when run_flow_on_task is called with a flow that has no instantiated model and all dependencies are satisfied (with the right version). I think we should involve @mfeurer on if/how/when we want to allow disabling version checks and how it should behave.
importopenmltask=openml.tasks.get_task(3)
flow=openml.flows.get_flow(7684, reinstantiate=True) # Necessary otherwise no model is made.run=openml.runs.run_flow_on_task(flow, task)
yields
ValueError: Trying to deserialize a model with dependency sklearn==0.19.1 not satisfied.
Activity
PGijsbers commentedon Jun 25, 2019
Sorry for the delay.
To reproduce the issue, please let us know which flow and/or setup you are working with.
That said, running a flow on a task is easiest done in the following way (e.g.
task 3andflow 7684):Note the one line in the middle, where the model is reinstantiated after downloading the flow. I think it's fair to say that we should check for this automatically in the
run_flow_on_taskmethod.hp2500 commentedon Jun 25, 2019
Hi, thanks a lot for your reply! I have tried your code, but it seems to require an older sklearn version.
I am using sklearn version 0.21.2, because I am interested in some functions that were added only recently. Do you think there is a workaround?
P.S. I originally used flow #6970, but I don't think it matters because I am getting the same errors for different flow ids.
@amueller
hp2500 commentedon Jun 25, 2019
But maybe, the required sklearn version depends on which version was used in the original flow... When I try a different flow, the error mentions a different sklearn version.
@amueller
PGijsbers commentedon Jun 25, 2019
Yes, that is the case. The flows require a specific
scikit-learnversion to ensure reproducibility. I don't believe there currently is a way to automatically create a new flow for your scikit-learn version based on a flow-id and your current environment (or find one on the server that matches). I can understand this would be a desirable feature, which for pure-scikit-learn based flows should be feasible.A little disclaimer, I was not involved at the time this flow (6970) was created or the related study (study14) was done. With that said, it looks like the flow you are trying to deserialize (6970) in particular also relies on non-scikit-learn components (
openmlstudy14.preprocessing.ConditionalImputer). I don't currently know the status of reproducing that scenario, perhaps @mfeurer knows. I image you need to make sure the original source code can be found (https://github.com/openml/Study-14), which @janvanrijn should be more familiar with.Sorry to not be of more use.
amueller commentedon Jun 27, 2019
@PGijsbers Thanks for all the replies! It would be great to do the instantiation automatically for
run_flow_on_task. I couldn't find that in the documentation and the error message is not very helpful. Maybe either you or @hp2500 can just add this to the error message for now.I don't think instantiating Study-14 pipelines should be a high priority (there is no setup.py). We were actually more interested in getting the parameters of the last pipeline step. To do that, we could in principle just use mocking to replace the ContitionalImputer just so we can call
pipeline[-1].get_params(). But maybe that's to specialized.More generally I think it would be good to optionally disable the version check if the libraries are available.
PGijsbers commentedon Jun 28, 2019
I'll make the change to automatically reinstantiate the model when
run_flow_on_taskis called with a flow that has no instantiated model and all dependencies are satisfied (with the right version). I think we should involve @mfeurer on if/how/when we want to allow disabling version checks and how it should behave.mfeurer commentedon Jul 8, 2019
We could create different levels of checks for this:
Would this together with #722 solve this issue?
mfeurer commentedon Jul 9, 2019
Fixed via #724. Please reopen if that's not the case.
amueller commentedon Jul 22, 2019
yields