enum

Cadmium::Classifier::Tabular::DistanceMetric

Inherits Enum < Comparable < Value < Object

Distance metrics for calculating similarity between feature vectors.

Used primarily by KNN to find nearest neighbors.

Constants

Euclidean = 0

Euclidean distance: √Σ(aᵢ - bᵢ)² Most common distance metric, works well for most cases

Manhattan = 1

Manhattan distance: Σ|aᵢ - bᵢ| Also known as L1 distance or city block distance Less sensitive to outliers than Euclidean

Chebyshev = 2

Chebyshev distance: max|aᵢ - bᵢ| Also known as L∞ distance or chessboard distance Useful for grid-like data

Cosine = 3

Cosine distance: 1 - (a·b)/(||a||·||b||) Measures angular similarity, ignores magnitude Useful for high-dimensional data

Instance methods

chebyshev?

Returns true if this enum value equals Chebyshev

Source
cosine?

Returns true if this enum value equals Cosine

Source
euclidean?

Returns true if this enum value equals Euclidean

Source
manhattan?

Returns true if this enum value equals Manhattan

Source