combination
combination
#
Several per-dimension metrics over one session, fused as a Euclidean norm.
Each term names a session attribute and the metric that measures it; the
attribute's type is the term's own business, which is why a term is typed as a
distance over Never — the bound every metric satisfies.
Term = tuple[str, DistanceFunction[Never]]
#
An attribute path and the metric measuring the values found there.
CombinedDistance
#
Bases: DistanceFunction[object]
Each term's distance along its own attribute path, combined in L2.
Source code in capturegraph-recipes/capturegraph_recipes/scheduling/distance/combination.py
__init__(terms)
#
extract(values)
#
Each term's features for the value at its own attribute path.
Source code in capturegraph-recipes/capturegraph_recipes/scheduling/distance/combination.py
pairwise(features_a, features_b)
#
The L2 norm over the terms both sides define (nan when none do).
Source code in capturegraph-recipes/capturegraph_recipes/scheduling/distance/combination.py
combine(**metrics)
#
Combine per-dimension distance functions into a single session metric.
Each keyword names the session attribute its metric reads, and the combined
distance is the Euclidean norm over those terms:
d = sqrt(d1² + d2² + ... + dn²). A term whose attribute is absent on
either side drops out; a pair with no surviving term has no distance, and
select_sessions never offers such a candidate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**metrics
|
Callable[[Never, Never], float]
|
Named distance functions — |
{}
|
Returns:
| Type | Description |
|---|---|
CombinedDistance
|
A combined metric: |
CombinedDistance
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no distance function is given. |