question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compositions return individual steps as part of get_params

See original GitHub issue

Describe the bug

When calling get_params on an Pipeline or a ColumnTransformer, it returns the steps as parameters as well. However, the docs for get_params says that only the arguments to __init__ will be returned. By having additional entries here, the output of get_params can no longer be used to call __init__.

Steps/Code to Reproduce

import sklearn.preprocessing
from sklearn.compose import ColumnTransformer

model_original = sklearn.pipeline.Pipeline(
    steps=[("transform", 'passthrough')]
)
print(model_original.get_params().keys())
ct = ColumnTransformer(
    [("continous", "passthrough", [])]
)
print(ct.get_params().keys())

params = ct.get_params()
ColumnTransformer(**params)

Expected Results

dict_keys(['memory', 'steps', 'verbose'])
dict_keys(['n_jobs', 'remainder', 'sparse_threshold', 'transformer_weights', 'transformers', 'verbose'])

Actual Results

dict_keys(['memory', 'steps', 'verbose', 'transform'])
dict_keys(['n_jobs', 'remainder', 'sparse_threshold', 'transformer_weights', 'transformers', 'verbose', 'continous'])
Traceback (most recent call last):
  File "/home/feurerm/sync_dir/projects/openml/python/local/bug3.py", line 14, in <module>
    ColumnTransformer(**params)
  File "/home/feurerm/miniconda/3-4.5.4/envs/openml/lib/python3.7/site-packages/sklearn/utils/validation.py", line 72, in inner_f
    return f(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'continous'

Versions

Python 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0] NumPy 1.17.0 SciPy 1.3.0 Scikit-Learn 0.23.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
glemaitrecommented, Aug 28, 2020

I made a proposal there: https://github.com/scikit-learn/scikit-learn/pull/18285

  • it gives an example in the developer guide of what deep is useful for
  • update the docstring of get_params and set_params to be more explicit regarding what will be returned or set.
0reactions
mfeurercommented, Aug 28, 2020

I am thinking that the docstring of get_params and set_params of the estimator inheriting from _BaseComposition could be more explicit regarding the fact that you can set or get parameters from the steps or transformers, which are not given in init.

I think that would be great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TF1 Class Reference - ROOT
Returns the first derivative of the function at point x, computed by Richardson's extrapolation method (use 2 derivative estimates to compute a third,...
Read more >
How to get route url params in a page in Nuxt2 and 3?
It will be called server-side once (on the first request to the Nuxt app) and client-side when navigating to further routes. ref.
Read more >
AudioManager - Android Developers
Return value for getDirectPlaybackSupport(android.media.AudioFormat, android.media.AudioAttributes) : direct offload playback supported with gapless ...
Read more >
Passing parameters to routes - React Navigation
Pass params to a route by putting them in an object as a second parameter to the navigation.navigate function: navigation.navigate('RouteName', { /* params...
Read more >
parse_url - Manual - PHP
This function parses a URL and returns an associative array containing any of the various components of the URL that are present.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found