pub enum DistanceMetric {
Cosine,
Euclidean,
DotProduct,
}Expand description
Distance metric used for nearest-neighbor comparisons.
Variants§
Cosine
Cosine distance: 1 - cos(a, b). Range [0, 2]. 0 = identical direction.
Euclidean
Euclidean (L2) distance. Range [0, inf).
DotProduct
Negative dot product (so smaller = more similar). Range (-inf, inf).
Implementations§
Source§impl DistanceMetric
impl DistanceMetric
Sourcepub fn compute(&self, a: &ArrayView1<'_, f32>, b: &ArrayView1<'_, f32>) -> f32
pub fn compute(&self, a: &ArrayView1<'_, f32>, b: &ArrayView1<'_, f32>) -> f32
Compute the distance between two vectors using this metric.
Trait Implementations§
Source§impl Clone for DistanceMetric
impl Clone for DistanceMetric
Source§fn clone(&self) -> DistanceMetric
fn clone(&self) -> DistanceMetric
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DistanceMetric
impl Debug for DistanceMetric
Source§impl PartialEq for DistanceMetric
impl PartialEq for DistanceMetric
impl Copy for DistanceMetric
impl Eq for DistanceMetric
impl StructuralPartialEq for DistanceMetric
Auto Trait Implementations§
impl Freeze for DistanceMetric
impl RefUnwindSafe for DistanceMetric
impl Send for DistanceMetric
impl Sync for DistanceMetric
impl Unpin for DistanceMetric
impl UnsafeUnpin for DistanceMetric
impl UnwindSafe for DistanceMetric
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.