kumulant

KnnDistance

@Serializable
sealed interface KnnDistance(source)

A distance function a KnnContextualSpec can name on the wire.

Sealed rather than a string against a registry, so an unknown metric is a compile error and the wire format admits only metrics that exist. A caller wanting a metric that is not here passes a function to the KnnContextualBandit constructor directly; that path cannot round-trip through the wire format, which is the reason this hierarchy is closed.

Inheritors

Types

Link copied to clipboard
@Serializable
@SerialName(value = "SquaredL2")
data object SquaredL2 : KnnDistance

Squared Euclidean distance. Skips the square root, which no ranking needs.