Skip to contents

A scalar predicate over the same conversion table used by precise_transform(to = "distance"), which converts all rows or none.

Usage

pd_convertible_to_distance(metric, type, family)

Arguments

metric

Canonical registry name, or NA_character_ for a custom or unknown measure.

type

Native output type: "distance", "similarity", "correlation", "affinity", or NA_character_.

family

Registry family for the measure, or NA_character_.

Value

TRUE when a built-in distance conversion exists, otherwise FALSE.

Details

The result describes the conversion rule, not a particular matrix. The generic similarity rule additionally requires values in [0, 1], which precise_transform() can only check at run time.

The arguments correspond to the metric and type columns of a precise_dist() result plus the registry family behind that metric. Any argument may be NA_character_, and type = NA_character_ always returns FALSE.

See also

precise_transform(), which applies the conversion.

Examples

pd_convertible_to_distance("cosine", "similarity", "inner_product")
#> [1] TRUE
pd_convertible_to_distance("tsne_5", "affinity", "tsne")
#> [1] FALSE