19 unstable releases (6 breaking)

0.10.1 Sep 8, 2025
0.10.0 May 19, 2025
0.9.0 Jan 14, 2025
0.8.0 Dec 23, 2024
0.7.0 Nov 25, 2024

#9 in #outlier-detection

Download history 18/week @ 2025-08-08 125/week @ 2025-08-15 190/week @ 2025-08-22 141/week @ 2025-08-29 147/week @ 2025-09-05 161/week @ 2025-09-12 25/week @ 2025-09-19 43/week @ 2025-09-26 37/week @ 2025-10-03 51/week @ 2025-10-10 41/week @ 2025-10-17 16/week @ 2025-10-24

1,802 downloads per month
Used in 3 crates (via augurs)

MIT/Apache

1.5MB
543 lines

Time series clustering algorithms

Time series clustering algorithms.

So far, only DBSCAN is implemented, and the distance matrix must be passed directly. A crate such as augurs-dtw must be used to calculate the distance matrix for now.

Usage

use augurs::clustering::{DbscanCluster, DbscanClusterer, DistanceMatrix};

# fn main() -> Result<(), Box<dyn std::error::Error>> {
// Start with a distance matrix.
// This can be calculated using e.g. dynamic time warping
// using the `augurs-dtw` crate.
let distance_matrix = DistanceMatrix::try_from_square(
    vec![
        vec![0.0, 0.1, 0.2, 2.0, 1.9],
        vec![0.1, 0.0, 0.15, 2.1, 2.2],
        vec![0.2, 0.15, 0.0, 2.2, 2.3],
        vec![2.0, 2.1, 2.2, 0.0, 0.1],
        vec![1.9, 2.2, 2.3, 0.1, 0.0],
    ],
)?;

// Epsilon is the maximum distance between two series for them to be considered in the same cluster.
let epsilon = 0.3;
// The minimum number of series in a cluster before it is considered non-noise.
let min_cluster_size = 2;

// Use DBSCAN to detect clusters of series.
// Note that we don't need to specify the number of clusters in advance.
let clusters = DbscanClusterer::new(epsilon, min_cluster_size).fit(&distance_matrix);
assert_eq!(
    clusters,
    vec![
        DbscanCluster::Cluster(1.try_into().unwrap()),
        DbscanCluster::Cluster(1.try_into().unwrap()),
        DbscanCluster::Cluster(1.try_into().unwrap()),
        DbscanCluster::Cluster(2.try_into().unwrap()),
        DbscanCluster::Cluster(2.try_into().unwrap()),
    ],
);
# Ok(())
# }

Credits

This implementation is based heavily on to the implementation in linfa-clustering and scikit-learn. The main difference between these is that we operate directly on the distance matrix rather than calculating it as part of the clustering algorithm.

License

Dual-licensed to be compatible with the Rust project. Licensed under the Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <http://opensource.org/licenses/MIT>, at your option.

Dependencies