{"action":"closed","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10524","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10524/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10524/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10524/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/10524","id":291014826,"number":10524,"title":"BaseEstimator.set_params(**params) is not truly recursive","user":{"login":"pavelkomarov","id":5639551,"avatar_url":"https://avatars0.githubusercontent.com/u/5639551?v=4","gravatar_id":"","url":"https://api.github.com/users/pavelkomarov","html_url":"https://github.com/pavelkomarov","followers_url":"https://api.github.com/users/pavelkomarov/followers","following_url":"https://api.github.com/users/pavelkomarov/following{/other_user}","gists_url":"https://api.github.com/users/pavelkomarov/gists{/gist_id}","starred_url":"https://api.github.com/users/pavelkomarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavelkomarov/subscriptions","organizations_url":"https://api.github.com/users/pavelkomarov/orgs","repos_url":"https://api.github.com/users/pavelkomarov/repos","events_url":"https://api.github.com/users/pavelkomarov/events{/privacy}","received_events_url":"https://api.github.com/users/pavelkomarov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-01-23T22:21:57Z","updated_at":"2018-04-02T16:42:11Z","closed_at":"2018-04-02T16:42:11Z","author_association":"NONE","body":"I am trying to set the hyperparameters of the `base_estimator` of an `AdaBoostRegressor` inside a `MultioutputRegressor`. I've defined a parameters dictionary as:\r\n\r\n    params = {'estimator__base_estimator': DecisionTreeRegressor(),\r\n        'estimator__loss': 'square',\r\n        'estimator__learning_rate': 0.05,\r\n        'estimator__n_estimators': 50,\r\n        'estimator__base_estimator__max_features': 'sqrt',\r\n        'estimator__base_estimator__max_leaf_nodes': 8\r\n    }\r\n\r\nThe values here aren't important, just the keys. When I call `set_params(**params)` it uses `get_params` with `deep=True` to find the parameters of the model and the sub-model. Great, except I also need to be able to tell the parameters of the sub-sub-model are valid and then set them.\r\n\r\nI see that `get_params` calls itself but doesn't pass down `deep=True`, so I copied and used a version of my own where I did pass `deep` down. The trouble I ran in to then was that the sub-sub-model is a parameter of the sub-model and hasn't been set yet, so somewhere down the stack the call `value.get_params(deep=True).items()` fails when `value` is `None`, because `value` is the `base_estimator` of the `AdaboostRegressor` and hasn't been set yet.\r\n\r\nI managed to hack a workaround in my code by only passing the parameters that have keys with less than two `'__'` substrings and then setting the subobject with the other subset of the `params` dictionary, but I would really like it if `set_params()` were truly completely generalized to arbitrarily deep structures. This will probably involve intelligently setting objects at each layer before going deeper.\r\n\r\n"}}
{"actor":{"display_login":"pavelkomarov"}}