{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11618","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11618/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11618/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11618/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/11618","id":342194340,"node_id":"MDU6SXNzdWUzNDIxOTQzNDA=","number":11618,"title":"TransforemdTargetRegressor fit calls to transformer.fit twice","user":{"login":"vahidbas","id":7312579,"node_id":"MDQ6VXNlcjczMTI1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/7312579?v=4","gravatar_id":"","url":"https://api.github.com/users/vahidbas","html_url":"https://github.com/vahidbas","followers_url":"https://api.github.com/users/vahidbas/followers","following_url":"https://api.github.com/users/vahidbas/following{/other_user}","gists_url":"https://api.github.com/users/vahidbas/gists{/gist_id}","starred_url":"https://api.github.com/users/vahidbas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vahidbas/subscriptions","organizations_url":"https://api.github.com/users/vahidbas/orgs","repos_url":"https://api.github.com/users/vahidbas/repos","events_url":"https://api.github.com/users/vahidbas/events{/privacy}","received_events_url":"https://api.github.com/users/vahidbas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-07-18T06:32:58Z","updated_at":"2018-07-19T02:16:24Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nIf your issue is a usage question, submit it here instead:\r\n- StackOverflow with the scikit-learn tag: http://stackoverflow.com/questions/tagged/scikit-learn\r\n- Mailing List: https://mail.python.org/mailman/listinfo/scikit-learn\r\nFor more information, see User Questions: http://scikit-learn.org/stable/support.html#user-questions\r\n-->\r\n\r\n<!-- Instructions For Filing a Bug: https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md#filing-bugs -->\r\n\r\n#### Description\r\nOnce transformer fit is done [here](https://github.com/scikit-learn/scikit-learn/blob/da138c5f78e5a4bab0f5a8eea2591e0f25474db0/sklearn/compose/_target.py#L178) and again [here](https://github.com/scikit-learn/scikit-learn/blob/da138c5f78e5a4bab0f5a8eea2591e0f25474db0/sklearn/compose/_target.py#L187) during fit_transform. I don't think this is intended as fitting can be costly and there is no reason to repeat it for the same data.\r\n\r\n#### Steps/Code to Reproduce\r\n```python\r\nfrom sklearn.base import TransformerMixin, BaseEstimator\r\nfrom sklearn.compose import TransformedTargetRegressor\r\nfrom sklearn.tree import DecisionTreeRegressor\r\nfrom sklearn import datasets\r\n\r\nclass DummyTransformer(BaseEstimator, TransformerMixin):\r\n    def __init__(self):\r\n        pass\r\n    \r\n    def fit(self, X):\r\n        print('in fit')\r\n        return self\r\n    \r\n    def transform(self, X):\r\n        print('in transform')\r\n        return X\r\n    \r\n    def inverse_transform(self, X):\r\n        print('in inverse_transform')\r\n        return X\r\n    \r\n    \r\nestimator = TransformedTargetRegressor(\r\n    regressor=DecisionTreeRegressor(),\r\n    transformer=DummyTransformer(),\r\n    check_inverse = False\r\n)\r\n\r\nX, y = datasets.load_linnerud(return_X_y=True)\r\n\r\nestimator.fit(X, y)\r\n```\r\nreturns:\r\n```\r\nin fit\r\nin fit\r\nin transform\r\n```\r\n\r\n\r\n\r\n#### Expected Results\r\n```\r\nin fit\r\nin transform\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/406132733","html_url":"https://github.com/scikit-learn/scikit-learn/issues/11618#issuecomment-406132733","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11618","id":406132733,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjEzMjczMw==","user":{"login":"jnothman","id":78827,"node_id":"MDQ6VXNlcjc4ODI3","avatar_url":"https://avatars2.githubusercontent.com/u/78827?v=4","gravatar_id":"","url":"https://api.github.com/users/jnothman","html_url":"https://github.com/jnothman","followers_url":"https://api.github.com/users/jnothman/followers","following_url":"https://api.github.com/users/jnothman/following{/other_user}","gists_url":"https://api.github.com/users/jnothman/gists{/gist_id}","starred_url":"https://api.github.com/users/jnothman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnothman/subscriptions","organizations_url":"https://api.github.com/users/jnothman/orgs","repos_url":"https://api.github.com/users/jnothman/repos","events_url":"https://api.github.com/users/jnothman/events{/privacy}","received_events_url":"https://api.github.com/users/jnothman/received_events","type":"User","site_admin":false},"created_at":"2018-07-19T02:16:24Z","updated_at":"2018-07-19T02:16:24Z","author_association":"MEMBER","body":"No maybe it's not about FunctionTransformer. I'm not sitting down now to try replicate/debug"}}
{"actor":{"display_login":"jnothman"}}