[ENH] Added sample_weight parameter#631
Closed
ParamThakkar123 wants to merge 1 commit intosktime:mainfrom
Closed
Conversation
fkiraly
reviewed
Nov 17, 2025
| np.vstack((y_pred[:i, :], y_pred[i + 1 :, :])), # noqa | ||
| self.multioutput, | ||
| **kwargs, | ||
| if isinstance(y_true, np.ndarray): |
Collaborator
There was a problem hiding this comment.
could you explain why the case distinction based on if isinstance(y_true, np.ndarray)? How does introducing sample_weight change this?
Contributor
Author
There was a problem hiding this comment.
The isinstance(y_true, np.ndarray) branch exists because the code removes the i-th sample using NumPy slicing/stacking which only works reliably for plain NumPy arrays. Adding sample_weight requires removing the same sample from the weight array/Series with the same method (np.delete/mask for NumPy or .iloc/.drop for pandas) to keep alignment, otherwise metrics might become incorrect?
Collaborator
There was a problem hiding this comment.
- what are the two cases that this tries to cover, exactly?
- why do we not need to do this before your change?
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.
Reference Issues/PRs
Fixes #369
What does this implement/fix? Explain your changes.
This PR adds a new
sample_weightparameter to metrics as described in #369Does your contribution introduce a new dependency? If yes, which one?
What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
Any other comments?
I am open to suggestions to change this PR according to the reviewers.
PR checklist
For all contributions
How to: add yourself to the all-contributors file in the
skproroot directory (not theCONTRIBUTORS.md). Common badges:code- fixing a bug, or adding code logic.doc- writing or improving documentation or docstrings.bug- reporting or diagnosing a bug (get this pluscodeif you also fixed the bug in the PR).maintenance- CI, test framework, release.See here for full badge reference
For new estimators
docs/source/api_reference/taskname.rst, follow the pattern.Examplessection.python_dependenciestag and ensureddependency isolation, see the estimator dependencies guide.