Drop the sample_weight entry from GMM.fit's docstring - #741
Open
VenishPaneliya wants to merge 1 commit into
Open
Drop the sample_weight entry from GMM.fit's docstring#741VenishPaneliya wants to merge 1 commit into
VenishPaneliya wants to merge 1 commit into
Conversation
`GMM.fit` is `fit(self, X, y=None)`, but its docstring documents a third
argument:
sample_weight : array-like, shape (n_samples,)
Per-sample weights. Rescale C per sample. Higher weights
force the classifier to put more emphasis on these points.
Passing it raises `TypeError: GMM.fit() got an unexpected keyword
argument 'sample_weight'`.
The text is copied from `OCSVM.fit`, which does take the argument - "C"
is the SVM penalty parameter and has no counterpart in a Gaussian
mixture. It also cannot simply be forwarded: `sklearn.mixture
.GaussianMixture.fit` is `fit(self, X, y)` and has no `sample_weight`.
Only the stale documentation is removed; OCSVM is untouched.
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.
What this fixes
GMM.fithas the signaturefit(self, X, y=None), but its docstring documents a third argument:There's no
**kwargsto absorb it, so following the documentation fails:Two things say this is a stray copy rather than a missing feature:
OCSVM.fit, which really does takesample_weight(fit(self, X, y=None, sample_weight=None, **params)). "Rescale C per sample" refers to the SVM penalty parameter, which has no counterpart in a Gaussian mixture — and a GMM is not a classifier.sklearn.mixture.GaussianMixture.fitisfit(self, X, y)with nosample_weight.So the only correct reconciliation is removing the documentation.
OCSVMis untouched — it documents the argument correctly because it accepts it.GMMandOCSVMare the only two detectors inpyod/models/whosefitdocstring mentionssample_weight; OCSVM is the correct one.Testing
Documentation-only, so no behaviour to test:
pyod/test/test_gmm.py: 14 passedOCSVM().fit(X, sample_weight=w)still works andGMM.fit's signature is unchangedflake8reports the same single pre-existing finding as an unmodified checkout