class
Cadmium::Classifier::Tabular::DistanceCalculator
- Cadmium::Classifier::Tabular::DistanceCalculator
- Reference
- Object
Overview
Calculates distances between feature vectors using various metrics.
All methods accept num.cr Tensors for efficient vectorized operations.
Defined in:
cadmium/classifier/tabular/distance_metrics.crClass Method Summary
-
.calculate(a : Tensor(Float64, CPU(Float64)), b : Tensor(Float64, CPU(Float64)), metric : DistanceMetric) : Float64
Calculate the distance between two vectors using the specified metric.
Class Method Detail
def self.calculate(a : Tensor(Float64, CPU(Float64)), b : Tensor(Float64, CPU(Float64)), metric : DistanceMetric) : Float64
#
Calculate the distance between two vectors using the specified metric.
a = Tensor.from_array([1.0, 2.0, 3.0])
b = Tensor.from_array([1.1, 2.1, 3.1])
DistanceCalculator.calculate(a, b, DistanceMetric::Euclidean)
# => 0.1732...