8000 TransformedTargetRegressor returns the wrong _estimator_type with a classifier · Issue #15872 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

TransformedTargetRegressor returns the wrong _estimator_type with a classifier #15872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dabana opened this issue Dec 12, 2019 · 3 comments
Closed

Comments

@dabana
Copy link
dabana commented Dec 12, 2019

Description

TransformedTargetRegressor returns the wrong _estimator_type when a classifier is passed as the regressor parameter.

Steps/Code to Reproduce

TransformedTargetRegressor(regressor=LogisticRegression())._estimator_type

Expected Results

'classifier'

Actual Results

'regressor'

Versions

System:
python: 3.7.2 (default, Jan 2 2019, 17:07:39) [MSC v.1915 64 bit (AMD64)]
executable: C:\Users\david\Anaconda3\envs\laserag_py37_skl0202\python.exe
machine: Windows-10-10.0.17763-SP0

Python dependencies:
pip: 18.1
setuptools: 41.0.1
sklearn: 0.22
numpy: 1.15.4
scipy: 1.1.0
Cython: 0.29.13
pandas: 0.25.1
matplotlib: 3.0.2
joblib: 0.14.0

Built with OpenMP: True

@chkoar
Copy link
Contributor
chkoar commented Dec 12, 2019

I suppose that this is the expected behavior, since as the name suggests, the TransformedTargetRegressor is a regressor. Thus, it inherits from RegressorMixin. So, the _estimator_type is inherited from that mixin. The thing you are proposing is to broader the context of that class and make it like TransformedTargetPredictor so the _estimator_type can be extracted from the estimator passed in. I do not know if it makes sense to transform the target for classification tasks. The ordinal classification might be an exception though.

@jnothman
Copy link
Member

Agreed. What's your use case for needing a TransformedTargetClassifier? What's your transformer?

@glemaitre
Copy link
Member

Agreed. What's your use case for needing a TransformedTargetClassifier? What's your transformer?

Since the use case here is "regression by classification" (something that @jnothman foreseen when developing the meta-estimator 👍 #9041 (comment)), it means that we want the estimator to be a classifier and apply a binarizer to transform the target. However, as I mentioned in #15850, we are still solving a regression problem and therefore the meta-estimator should use the default regression score and therefore should identify as a regressor.

Therefore, with the current use case, I would close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0