Skip to content

[ENH] Added sample_weight parameter#631

Closed
ParamThakkar123 wants to merge 1 commit intosktime:mainfrom
ParamThakkar123:add_sample_weight
Closed

[ENH] Added sample_weight parameter#631
ParamThakkar123 wants to merge 1 commit intosktime:mainfrom
ParamThakkar123:add_sample_weight

Conversation

@ParamThakkar123
Copy link
Copy Markdown
Contributor

@ParamThakkar123 ParamThakkar123 commented Nov 16, 2025

Reference Issues/PRs

Fixes #369

What does this implement/fix? Explain your changes.

This PR adds a new sample_weight parameter to metrics as described in #369

Does 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
  • I've added myself to the list of contributors with any new badges I've earned :-)
    How to: add yourself to the all-contributors file in the skpro root directory (not the CONTRIBUTORS.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 plus code if you also fixed the bug in the PR).maintenance - CI, test framework, release.
    See here for full badge reference
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

@ParamThakkar123 ParamThakkar123 changed the title Added sample_weight parameter [ENH] Added sample_weight parameter Nov 16, 2025
Comment thread skpro/metrics/base.py
np.vstack((y_pred[:i, :], y_pred[i + 1 :, :])), # noqa
self.multioutput,
**kwargs,
if isinstance(y_true, np.ndarray):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain why the case distinction based on if isinstance(y_true, np.ndarray)? How does introducing sample_weight change this?

Copy link
Copy Markdown
Contributor Author

@ParamThakkar123 ParamThakkar123 Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • what are the two cases that this tries to cover, exactly?
  • why do we not need to do this before your change?

@ParamThakkar123 ParamThakkar123 closed this by deleting the head repository Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] sample_weight for metrics

2 participants