Crates.io | faasle |
lib.rs | faasle |
version | 0.1.0 |
source | src |
created_at | 2024-08-31 09:09:51.793598 |
updated_at | 2024-08-31 09:09:51.793598 |
description | A Rust crate for evaluating distances (metrics) |
homepage | https://github.com/Qazalbash/faasle |
repository | https://github.com/Qazalbash/faasle |
max_upload_size | |
id | 1358682 |
size | 13,547 |
faasle
faasle
1 is a Rust package for evaluating distances (metrics) between multidimensional arrays. It is designed to be simple, fast, and easy to use.
use faasle::{Distance, Euclidean};
use ndarray::{ArrayD, Axis};
let x =
ArrayD::from_shape_vec(vec![2, 4], vec![0.0, 3.0, 3.0, 5.0, 11.0, 2.0, 0.0, 9.0]).unwrap();
let y =
ArrayD::from_shape_vec(vec![2, 4], vec![9.0, 2.0, 2.0, 1.0, 9.0, 5.0, 4.0, 7.0]).unwrap();
let metric = Euclidean::new();
let distance = metric.evaluate( & x, & y, Axis(1)).unwrap();
assert!(distance.abs_diff_eq(
&ArrayD::from_shape_vec(vec![2], vec![9.9498743710662, 5.744562646538029]).unwrap(),
1e-6
));
Mathematically a distance metric is a function $d:\mathcal{X}\times\mathcal{X}\rightarrow\mathbb{R}$, where $\mathcal{X}$ is a set, such that they satisfy the following properties:
The hierarchy of types and their properties are as follows:
PreMetric |
SemiMetric |
Metric |
|
---|---|---|---|
Positivity | ✅ | ✅ | ✅ |
Symmetry | ❌ | ✅ | ✅ |
Triangle Inequality | ❌ | ❌ | ✅ |
@software{faaslers2024github,
author = {{M}eesum {Q}azalbash},
title = {{faasle}: Rust crate for evaluating distances (metrics).},
url = {https://github.com/Qazalbash/faasle},
version = {0.0.1},
year = {2024}
}