tanat.metric.entity.type.l2_metric package#
Submodules#
tanat.metric.entity.type.l2_metric.metric module#
L2EntityMetric: numerical feature distance by L2 distance.
- class tanat.metric.entity.type.l2_metric.metric.L2EntityMetric(entity_feature: str | None = None, nan_cost: float = 1.0, normalize: bool = True)[source]#
Bases:
EntityMetricNumerical distance between two entities evaluated as the squared difference of values (no square root applied).
Returns the L2 distance between feature values when both are defined, and
nan_costvalue in case there is aNaN.If no
entity_featureprovided when the metric is created, a feature will be defined automatically as the first numerical attribute found when the metric is applied a first time to an entity. The updated feature name is then frozen for future usages. If there is no numerical attribute, an error is raised.Example:
metric = L2EntityMetric( entity_feature="value", nan_cost=0.8, ) metric(ent_a, ent_b)
The normalized version of the L2 metric evaluate the quantity $ rac{(f_1-f_2)^2}{f_1^2+f_2^2}$ that is between 0 (when $f_1$ equals $f_2$) and 1 (when $f_1$ is null for instance).
- NUMBA_OPTIM: bool = False[source]#
Subclasses that provide
prepare_batch_data/distance_kernel/ prepare_cross_batch_data set this toTrueto opt into the Numba fast path.
- SETTINGS_CLASS[source]#
alias of
L2Settings
- class tanat.metric.entity.type.l2_metric.metric.L2Settings(*, entity_feature: str | None = None, nan_cost: float = 1.0, normalize: bool = True)[source]#
Bases:
EntityMetricSettingsSettings for
L2EntityMetric.- Parameters:
entity_feature – Name of the numerical feature to compare.
None- first entity feature from the pool/entity metadata.nan_cost – Default cost applied when at least one value is NaN (default:
1.0).normalize – Compute the absolute relative difference of the values to ensure to have a value between 0 and 1.
Module contents#
L2EntityMetric package.
- class tanat.metric.entity.type.l2_metric.L2EntityMetric(entity_feature: str | None = None, nan_cost: float = 1.0, normalize: bool = True)[source]#
Bases:
EntityMetricNumerical distance between two entities evaluated as the squared difference of values (no square root applied).
Returns the L2 distance between feature values when both are defined, and
nan_costvalue in case there is aNaN.If no
entity_featureprovided when the metric is created, a feature will be defined automatically as the first numerical attribute found when the metric is applied a first time to an entity. The updated feature name is then frozen for future usages. If there is no numerical attribute, an error is raised.Example:
metric = L2EntityMetric( entity_feature="value", nan_cost=0.8, ) metric(ent_a, ent_b)
The normalized version of the L2 metric evaluate the quantity $ rac{(f_1-f_2)^2}{f_1^2+f_2^2}$ that is between 0 (when $f_1$ equals $f_2$) and 1 (when $f_1$ is null for instance).
- NUMBA_OPTIM: bool = False[source]#
Subclasses that provide
prepare_batch_data/distance_kernel/ prepare_cross_batch_data set this toTrueto opt into the Numba fast path.
- SETTINGS_CLASS[source]#
alias of
L2Settings
- class tanat.metric.entity.type.l2_metric.L2Settings(*, entity_feature: str | None = None, nan_cost: float = 1.0, normalize: bool = True)[source]#
Bases:
EntityMetricSettingsSettings for
L2EntityMetric.- Parameters:
entity_feature – Name of the numerical feature to compare.
None- first entity feature from the pool/entity metadata.nan_cost – Default cost applied when at least one value is NaN (default:
1.0).normalize – Compute the absolute relative difference of the values to ensure to have a value between 0 and 1.