docs(utility): correct score_to_label return description - #733
Open
godarrenw wants to merge 1 commit into
Open
Conversation
Signed-off-by: Zhu yizhang <95731595+godarrenw@users.noreply.github.com>
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
score_to_labeldocuments a return value it does not produce.Its
Returnssection currently ends with:but the function returns binary labels:
The summary line of the same docstring already says "Turn raw outlier scores to binary labels (0 or 1)", so the docstring contradicts itself. The wording appears to have been copied from
BaseDetector.predict_proba(base.py:205), which really does return probabilities.Running it confirms the behaviour:
which also matches
test_utility.py:198-204, where the expected values are asserted as0/1.This PR replaces that sentence with "Returns 0 for inliers and 1 for outliers."
It also drops a duplicated word on the summary line:
Turn raw outlier outlier scores→Turn raw outlier scores.Why it matters
score_to_labelis part of the public API — it is exported inpyod/utils/__init__.pyand listed in__all__— so this text is what users see when they read the docs or callhelp(), and it currently tells them to expect probabilities.How I checked
Read the implementation, ran the function against the same input the test suite uses, and compared with
predict_proba's docstring to identify where the wording came from.python -m py_compilepasses. Docstring only — no behaviour change.No open PR or issue covers this (
search/issuesforscore_to_labelreturned one unrelated result), so this PR does not close an existing issue._Disclosure: prepared with AI assistance; the return value was verified by running the function.