Repository navigation
Conversation
…exing This addresses issue scikit-learn#27439 by making _safe_indexing public, exposing it like other public functions. The function was already listed in the documentation despite being marked as private. Backward compatibility is maintained by keeping _safe_indexing as a reference to safe_indexing.
This change makes the previously private _safe_indexing function a public API by: - Renaming it to safe_indexing in sklearn.utils._indexing - Exposing it in sklearn.utils.__init__ - Adding backward compatibility for _safe_indexing
Update test_indexing.py to use the new public API name. This ensures test coverage for the newly exposed function.
Update references in ColumnTransformer and TransformedTargetRegressor to use the public API name.
…fe_indexing Update references in the permutation importance module to use the public API name.
… _safe_indexing Update references in the model selection validation module to use the public API name.
Update documentation to reference the new public API name.
dokterbob
force-pushed
the
make-safe-indexing-public
branch
2 times, most recently
from
March 24, 2025 11:25
e708187 to
4147095
Compare
dokterbob
commented
Mar 24, 2025
| Indexes the data on its second axis. Integers are interpreted as | ||
| positional columns, while strings can reference DataFrame columns | ||
| by name. A scalar string or int should be used where | ||
| by name. A scalar string or int should be used where |
Collaborator
Author
There was a problem hiding this comment.
Randomly added whitespace!??
| - callable: a scorer callable object (e.g., function) with signature | ||
| ``scorer(estimator, X, y)``, which should return only a single value. | ||
| See :ref:`scoring_callable` for details. | ||
| ``scorer(estimator, X, y)``. See :ref:`scoring_callable` for details. |
Collaborator
Author
There was a problem hiding this comment.
Irrelevant change. Possibly due to linter line-length feedback.
| If replace is False it should not be larger than the length of | ||
| arrays. | ||
| automatically set to the first dimension of the arrays. If replace is False it | ||
| should not be larger than the length of arrays. |
Collaborator
Author
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses issue scikit-learn#27439 by making
_safe_indexingpublic, exposing it like other public functions in the scikit-learn API.Currently,
_safe_indexingis the only private utility function listed in the documentation, which is inconsistent with the project's API design. As discussed in the issue, this function is widely used internally and could be useful for third-party libraries that want to comply with scikit-learn's estimator API.Changes
_safe_indexingtosafe_indexing(removing the leading underscore)_safe_indexingas a reference to the new public functionsafe_indexingto the__all__list insklearn.utils.__init__References
Fixes scikit-learn#27439
Additional Information
Backward compatibility is fully preserved as the original
_safe_indexingfunction continues to work as before, now implemented as a thin wrapper around the public API function.This PR follows all guidelines from scikit-learn's contribution standards.