Skip to content

TST Add TransformedTargetRegressor to test_meta_estimators_delegate_data_validation #20175

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

Merged
merged 7 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sklearn/compose/_column_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ class ColumnTransformer(TransformerMixin, _BaseComposition):

.. versionadded:: 1.0

n_features_in_ : int
Number of features seen during :term:`fit`. Only defined if the
underlying transformers expose such an attribute when fit.

.. versionadded:: 0.24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not covered by common tests, maybe we should add a dedicated test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many untested estimators. I'd rather try to find a way to include more estimators in the common tests. We've already started to discuss that with @glemaitre.


Notes
-----
The order of the columns in the transformed feature matrix follows the
Expand Down
6 changes: 6 additions & 0 deletions sklearn/compose/_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class TransformedTargetRegressor(RegressorMixin, BaseEstimator):
transformer_ : object
Transformer used in ``fit`` and ``predict``.

n_features_in_ : int
Number of features seen during :term:`fit`. Only defined if the
underlying regressor exposes such an attribute when fit.

.. versionadded:: 0.24

Examples
--------
>>> import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion sklearn/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_search_cv(estimator, check, request):
#
# check_classifiers_train would need to be updated with the error message
N_FEATURES_IN_AFTER_FIT_MODULES_TO_IGNORE = {
'compose',
'feature_extraction',
'model_selection',
'multiclass',
'multioutput',
Expand Down
2 changes: 1 addition & 1 deletion sklearn/tests/test_metaestimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _generate_meta_estimator_instances_with_pipeline():
for _, Estimator in sorted(all_estimators()):
sig = set(signature(Estimator).parameters)

if "estimator" in sig or "base_estimator" in sig:
if "estimator" in sig or "base_estimator" in sig or "regressor" in sig:
if is_regressor(Estimator):
estimator = make_pipeline(TfidfVectorizer(), Ridge())
param_grid = {"ridge__alpha": [0.1, 1.0]}
Expand Down