#knee-point #knee #kneedle

kneed

Pure rust implementation of Knee-point detection

4 releases (1 stable)

1.0.0 Aug 24, 2024
0.3.0 Aug 24, 2024
0.2.0 Jun 30, 2024
0.1.0 Jun 29, 2024

#302 in Math

Download history 252/week @ 2024-08-24 6/week @ 2024-08-31 34/week @ 2024-09-14 25/week @ 2024-09-21 40/week @ 2024-09-28 28/week @ 2024-10-05 73/week @ 2024-10-12 38/week @ 2024-10-19 4/week @ 2024-10-26 44/week @ 2024-11-02 10/week @ 2024-11-09 8/week @ 2024-11-16 1/week @ 2024-11-23

64 downloads per month

BSD-3-Clause

57KB
1.5K SLoC

kneed

build

This is a pure rust implementation of Knee-point detection.

The code here aims to be a 1:1 match of kneed.

Usage

General usage:

// Provide your x: Vec<f64> and y: Vec<f64>
let x = [1.0, 2.0, 3.0];
let y = [10.0, 20.0, 30.0];
let params = KneeLocatorParams::new(
    ValidCurve::Concave,
    ValidDirection::Increasing,
    InterpMethod::Interp1d,
);

// Instantiate KneeLocator
let kl = KneeLocator::new(x.to_vec(), y.to_vec(), 1.0, params);

// After instantiation, you can invoke the following:
// kl.knee
// kl.knee_y
// kl.norm_knee
// kl.norm_knee_y
// kl.elbow()
// kl.norm_elbow()
// kl.elbow_y()
// kl.norm_elbow_y()
// kl.all_elbows()
// kl.all_norm_elbows()
// kl.all_elbows_y()
// kl.all_norm_elbows_y()

Example from the paper:

let (x, y) = DataGenerator::figure2();

let params = KneeLocatorParams::new(
    ValidCurve::Concave,
    ValidDirection::Increasing,
    InterpMethod::Interp1d,
);
let kneedle = KneeLocator::new(x.to_vec(), y.to_vec(), 1.0, params);

assert_relative_eq!(0.222222222222222, kneedle.knee.unwrap());
assert_relative_eq!(1.8965517241379306, kneedle.knee_y.unwrap());

Credits

All credit for the python implementation goes to Kevin Arvai.

Dependencies

~3.5MB
~75K SLoC