Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions docs/modules/misc/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,39 @@ transformation followed by another metric:
:toctree: autosummary

skfda.misc.metrics.TransformationMetric


Product metric for mixed data
-----------------------------

In applications involving heterogeneous data—such as combinations of
scalar values and functional observations—it is often useful to define
a metric that captures distances across all components in a consistent
way. The following class implements a weighted product metric that
supports combining multiple data types, each potentially requiring
a different metric.

This class generalizes the idea of computing a norm over a product
space, where each component may be associated with a different scale
or importance. It supports common functional data representations
(:class:`~skfda.representation.FDataGrid`,
:class:`~skfda.representation.FDataBasis`), numeric arrays, and
:class:`pandas.DataFrame` objects mixing them.

.. autosummary::
:toctree: autosummary

skfda.misc.metrics.PProductMetric
skfda.misc.metrics.pproduct_metric
skfda.misc.metrics.DefaultMetric

The metric is defined as a weighted :math:`L^p`` norm of component-wise
distances. Each component may be assigned its own metric and weight,
allowing fine-grained control over the overall distance calculation.
This is especially useful in machine learning tasks that involve mixed
input types, such as classification or clustering over functional and
scalar features.

Functional wrappers for ease of use are also provided, along with a
default metric that infers the appropriate behavior depending on the
input type.
12 changes: 12 additions & 0 deletions skfda/misc/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"TransformationMetric",
"pairwise_metric_optimization",
],
"_pproduct_metric":[
"PProductMetric",
"pproduct_metric",
"DefaultMetric",
"default_metric",
],
},
)

Expand Down Expand Up @@ -63,6 +69,12 @@
)
from ._mahalanobis import MahalanobisDistance as MahalanobisDistance
from ._parse import PRECOMPUTED as PRECOMPUTED
from ._pproduct_metric import (
DefaultMetric as DefaultMetric,
PProductMetric as PProductMetric,
default_metric as default_metric,
pproduct_metric as pproduct_metric,
)
from ._utils import (
NormInducedMetric as NormInducedMetric,
PairwiseMetric as PairwiseMetric,
Expand Down
Loading