Repository navigation
sklearn converter does not work with new columntransformer #494
Copy link
Copy link
Closed
Description
Once sklearn 0.20 will be released, one of the key features is the column transformer (which we probably want to use for the benchmark study)
The current serialize function throws the following error. We should probably fix this.
Traceback (most recent call last):
File "/home/janvanrijn/projects/sklearn-bot/examples/run_on_study.py", line 47, in <module>
run()
File "/home/janvanrijn/projects/sklearn-bot/examples/run_on_study.py", line 43, in run
run = openml.runs.run_model_on_task(task, classifier)
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/runs/functions.py", line 39, in run_model_on_task
flow = sklearn_to_flow(model)
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 42, in sklearn_to_flow
rval = _serialize_model(o)
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 173, in _serialize_model
_extract_information_from_model(model)
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 281, in _extract_information_from_model
rval = sklearn_to_flow(v, model)
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 45, in sklearn_to_flow
rval = [sklearn_to_flow(element, parent_model) for element in o]
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 45, in <listcomp>
rval = [sklearn_to_flow(element, parent_model) for element in o]
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 45, in sklearn_to_flow
rval = [sklearn_to_flow(element, parent_model) for element in o]
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 45, in <listcomp>
rval = [sklearn_to_flow(element, parent_model) for element in o]
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 42, in sklearn_to_flow
rval = _serialize_model(o)
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 173, in _serialize_model
_extract_information_from_model(model)
File "/home/janvanrijn/anaconda3/envs/sklearn-bot/lib/python3.6/site-packages/openml/flows/sklearn_converter.py", line 292, in _extract_information_from_model
identifier, sub_component = sub_component_tuple
ValueError: too many values to unpack (expected 2)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
mfeurer commentedon Jul 27, 2018
Will OpenML support having multiple instantiations of the same flow by then?
And yes, we should fix this. I'll ask @ArlindKadra once everything else related to the benchmark study is done.
janvanrijn commentedon Sep 12, 2018
This will place a huge dependency on the scikit-learn version btw. Next week, we should really talk about decoupling openml-python and openml-scikitlearn
janvanrijn commentedon Sep 12, 2018
Something that came up in a conversation between @amueller and me.
In some way, it seemed weird that (de-)serializing a ColumnTransformer crashed. It seemed like a normal estimator, and should be serialized as such.
The reason that it crashed is that the openml-python converter assumes that all steps of a pipeline, voting classifier or feature union are lists of tuples of length 2. This is no longer the case for the ColumnTransformer, it is a list of tuples of length 3.
Fixing this is rather easy, although my current headache is how to fix this without further complicating the code. Please expect an PR very soon.
janvanrijn commentedon Sep 12, 2018
I committed a first attempt. I don't like it for the following reasons:
why does it serialize the name to:
sklearn.compose._column_transformer.ColumnTransformer(numeric=sklearn.preprocessing.data.StandardScaler, nominal=sklearn.preprocessing._encoders.OneHotEncoder)I didn't expect
_column_transformer,dataand_encodersthere.The columns on which is splits are now part of the flow definition. (should be part of the setup definition, IMO)
We need to have aliases for all components that are used double, but I guess we already knew that.
mfeurer commentedon Sep 13, 2018
Could you please post some example code?
janvanrijn commentedon Sep 13, 2018
Something like this?
janvanrijn commentedon Sep 13, 2018
I was btw wrong about shortcoming 1 and 2.
Shortcoming 1 is something that happens now for all test cases (all fixtures changed?) and shortcoming 2 is simply not true (my bad).
In order for us to merge this, we would need:
janvanrijn commentedon Sep 13, 2018
@mfeurer can we free some time for this on the workshop? There are many difficulties, mostly regarding how to handle version differences in test setup.
mfeurer commentedon Nov 16, 2018
This was added in #523 and #526.