base
base
#
What a distance function is: extract features, compare them pairwise.
Every metric implements two vectorized steps — extract turns values into
numeric features, pairwise turns two feature sets into a matrix of
distances — and inherits the scalar __call__ and the full matrix from
them.
Missing data has one rule, applied here: an absent value extracts as nan
features, so every pair involving it has nan distance. A combination drops
its nan terms, and is itself nan only when no term survives;
select_sessions never offers a candidate whose distance is nan.
DistanceFunction
#
Bases: ABC
A statistical distance between two values along one dimension.
Source code in capturegraph-lib/capturegraph/scheduling/distance/base.py
__call__(a, b)
#
The distance between two values (nan when they cannot be compared).
defined(values)
#
Which values this metric can compare at all, as a boolean mask.
extract(values)
abstractmethod
#
The numeric features of each value, one row each (nan when absent).
matrix(values_a, values_b=None)
#
The pairwise distances between two value sets (values_a against itself).
Source code in capturegraph-lib/capturegraph/scheduling/distance/base.py
pairwise(features_a, features_b)
abstractmethod
#
The len(a) × len(b) distances between two extracted feature sets.
as_distance(function)
#
function as a [DistanceFunction][], wrapping a plain callable as one.
Source code in capturegraph-lib/capturegraph/scheduling/distance/base.py
numeric(values, *fields)
#
Each value's fields as a row of floats — the value itself when none are named.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Array
|
The values to read. |
required |
fields
|
str
|
The field names to read from each value, in column order. |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
A |
ndarray
|
reads |