Skip to content

Suggesting updates on the doc of sklearn.compose.TransformedTargetRegressor #28473

@DocInspector

Description

@DocInspector

Describe the issue linked to the documentation

Hi,

We discover an inconsistency issue between documentation and code in the class sklearn.compose.TransformedTargetRegressor. As mentioned in the description of parameter func.

func: function, default=None
Function to apply to y before passing to fit. Cannot be set at the same time as transformer. The function needs to return a 2-dimensional array. If func is None, the function used will be the identity function.

The most relevant piece of source code looks like this:

if self.func is not None and self.inverse_func is None:
    raise ValueError(
        "When 'func' is provided, 'inverse_func' must also be provided"
    )

The error in the code mentioned that when func is provided, inverse_func must also be provided. The constraint is not mentioned in the document.

Could you please check it?

Suggest a potential alternative/fix

Maybe you can add the constraint into the document to avoid unnecessary misuse and extra debug efforts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions