Skip to content

Estimator Tags todo / proposed tags #13438

Open

Description

@amueller

Finally Estimator tags are merged (#6599, #8022) but there's still a lot to do.
We need to decide which tags to add and also use the tags more in the tests.
The following tags were proposed and I think might be useful:

  • supports sparse data
  • binary-only classifier
  • multi-label only classifier
  • positive data only
  • supports inverse transform?
  • support sample weights?
  • 1d inputs only?

The X_types field is not really thought through and we need to come up with a more general mechanism to generate input data for an estimator for testing.

We might also want to remove the _pairwise property and replace it by a tag.

Activity

  1. amueller commented on Mar 12, 2019

    @amueller
    MemberAuthor

    It was just proposed to me that we should have a tag for whether something takes y in fit at all. We kind of have the _estimator_type which is related, but also not really thought-through. We should maybe remove _estimator type and have something more coherent as tags.
    We could have all tags be boolean and have "supports_y_1d_regression" "supports_y_nd_regressor", "supports_multilabel", "supports_binary_classification" etc but that seems pretty verbose and also means that tags will often be True, while right now all tags are mostly False.
    This issue is kind of similar to the X_types.

  2. azrdev commented on May 3, 2019

    @azrdev
    • 1d inputs only?

    have a tag for whether something takes y in fit at all

    I suspect related to these are y-only transformers (see SLEP001: Transformers that modify their target)?

  3. reifba commented on Oct 4, 2019

    @reifba

    I think that adding, a tag of idempotency can tighten and help the estimator checks when building estimators.

    if should support something like:

    est = estimator()
    transformed_once = est.fit_transform(X)
    transformed_twice = est.fit_transform(transformed_once)
    assert transformed_once == transformed_twice

    StandardScaler is one such estimator.

  4. jeromedockes commented on Jun 5, 2026

    @jeromedockes
    Contributor

    Most of the suggestions in the original list seem to be covered now, except for "supports sample weights" AFAICT.

    Another one which could be useful IMO is a transformer tag to indicate if it outputs sparse data; from what I can tell currently it is only possible to know if sparse data is supported as input

  5. thomasjpfan commented on Jun 6, 2026

    @thomasjpfan
    Member

    from what I can tell currently it is only possible to know if sparse data is supported as input

    Is the proposal to add a output_tags somewhat like a InputTags?

    There are some variations with such an output tag:

    • OneHotEncoder(sparse_output=True) will always output sparse data. In this case, the output tag can be restricted to sparse.
    • StandardScalar(with_mean=False) returns sparse or dense data dependent on the input. Should the output tag input both dense and sparse output?
  6. jeromedockes commented on Jun 8, 2026

    @jeromedockes
    Contributor

    thank you @thomasjpfan , yes something like that , maybe an OutputTags.sparse which could be "always", "never", "same as input", or "maybe 🤷" when we really cannot know in advance -- for example a ColumnTransformer with 0 < sparse_threshold < 1

    One use-case I have in mind is: I am given an transformer by a user (in a third-party library, skrub ) and I call set_output on it so that it produces dataframes. I would like to know in advance if there is a risk it produces a sparse matrix and not do set_output in this case.

    (For that specific use-case it could also be solved, perhaps more robustly, by having an option to set_output that makes it less strict / allows it to give up on converting the output when it is sparse instead of raising an error, but that is less relevant to this issue. And I think there may be other situations where it is useful to know in advance if a transformer can output sparse data, definitely does, or definitely does not)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions