Skip to content

Weighted lp metric #690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open

Conversation

luisheb
Copy link
Contributor

@luisheb luisheb commented May 14, 2025

Describe the proposed changes

In some applications, it is useful to emphasize certain time points more than others when measuring the distance between functional observations. This can be achieved by introducing a weight function $w(t)$ inside the integral. The weight function assigns varying importance to different regions of the domain $\mathcal{T}$, resulting in a weighted $L^p$ norm.

These classes generalize the standard Lp norm and distance by supporting such weighting. This is useful in domains where relevance is time- or region-specific—such as emphasizing peak hours in energy data or symptom windows in medical signals.

Classes

  • skfda.misc.metrics.WeightedLpNorm
  • skfda.misc.metrics.WeightedLpDistance

Functional Wrappers

The following functional wrappers are provided for convenience, allowing direct evaluation of the norm or distance without explicitly creating a class instance:

  • skfda.misc.metrics.weighted_lp_norm
  • skfda.misc.metrics.weighted_lp_distance

These norms and distances are compatible with the same functionality that uses standard Lp norms, including classification pipelines, clustering algorithms, and pairwise distance computations.

Checklist before requesting a review

  • I have performed a self-review of my code
  • The code conforms to the style used in this package
  • The code is fully documented and typed (type-checked with Mypy)
  • I have added thorough tests for the new/changed functionality

@luisheb luisheb changed the title Feature/weighted lp Wighted lp metric May 14, 2025
@luisheb luisheb changed the title Wighted lp metric Weighted lp metric Jun 11, 2025
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

Attention: Patch coverage is 92.85714% with 12 lines in your changes missing coverage. Please review.

Project coverage is 87.11%. Comparing base (e44d8e5) to head (5785403).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
skfda/misc/metrics/_weighted_lp_norm.py 85.13% 11 Missing ⚠️
skfda/misc/metrics/_weighted_lp_distances.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #690      +/-   ##
===========================================
+ Coverage    87.04%   87.11%   +0.07%     
===========================================
  Files          199      202       +3     
  Lines        14639    14759     +120     
===========================================
+ Hits         12742    12858     +116     
- Misses        1897     1901       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@luisheb luisheb marked this pull request as ready for review June 18, 2025 23:08
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.

1 participant