Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Documentation: Incorrect description of statistic computed by MaxAbsScaler.partial_fit #34900

Description

@pradipgirhe

Warning

This issue is not yet ready for a PR. If you are interested in contributing to scikit-learn, please have a look at our contributing guidelines, and in particular the sections for new contributors and the "Needs triage" label.

Introduce yourself

Hi, I’m Pradip, a Computer Engineering student and I’m currently learning and working with Python and machine learning. I use scikit-learn for learning and implementing machine learning algorithms and preprocessing techniques.

While going through the MaxAbsScaler documentation and source code, I noticed a discrepancy in the partial_fit() docstring. I’m opening this issue to clarify the documentation and make it consistent with the actual implementation.

Describe the issue linked to the documentation

The X parameter description in MaxAbsScaler.partial_fit() currently states that the data is used to compute the "per-feature minimum and maximum".

However, MaxAbsScaler computes the maximum absolute value for each feature and stores it in max_abs_.

For example:

X = [[-2, 5],
     [-3, 1]]

For the first feature:

minimum = -3
maximum = -2
maximum absolute value = 3

MaxAbsScaler uses 3 as the scaling value. It does not use the minimum and maximum as separate statistics.

The implementation reflects this:

max_abs = xpx.nanmax(xp.abs(X), axis=0, xp=xp)

Therefore, the current wording may confuse users into thinking that MaxAbsScaler computes and uses both the minimum and maximum values independently.

This also appears inconsistent with the class-level documentation, which describes the scaler in terms of the maximum absolute value.

I believe this is a documentation-only issue and does not require any change to the underlying algorithm.

Suggest a potential alternative/fix

I suggest updating the X parameter description in MaxAbsScaler.partial_fit() from:

The data used to compute the per-feature minimum and maximum
used for later scaling along the features axis.

to:

The data used to compute the per-feature maximum absolute value
used for later scaling along the features axis.

This would make the partial_fit() documentation accurately reflect the statistic computed by the implementation and remain consistent with the class-level documentation.

Activity

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

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