#variance #functional #analysis #random #feature #mean #importance

fanova

A Rust implementation of fANOVA (functional analysis of variance)

3 unstable releases

0.2.0 Jul 1, 2022
0.1.1 Jul 22, 2020
0.1.0 Jul 19, 2020

#348 in Science

Download history 20/week @ 2023-11-20 50/week @ 2023-11-27 139/week @ 2023-12-04 8/week @ 2023-12-11 32/week @ 2023-12-18 15/week @ 2023-12-25 10/week @ 2024-01-15 31/week @ 2024-01-22 103/week @ 2024-01-29 55/week @ 2024-02-05 59/week @ 2024-02-12 105/week @ 2024-02-19 59/week @ 2024-02-26 23/week @ 2024-03-04

246 downloads per month

MIT license

38KB
922 lines

fanova

fanova Documentation Actions Status Coverage Status License: MIT

A Rust fANOVA (functional analysis of variance) implementation.

fANOVA provides a way to calculate feature importance.

Examples

use fanova::{FanovaOptions, RandomForestOptions};
use rand::{Rng, SeedableRng};

let mut feature1 = Vec::new();
let mut feature2 = Vec::new();
let mut feature3 = Vec::new();
let mut target = Vec::new();

let mut rng = rand::rngs::StdRng::seed_from_u64(0);
for _ in 0..100 {
    let f1 = rng.gen();
    let f2 = rng.gen();
    let f3 = rng.gen();
    let t = f1 + f2 * 2.0 + f3 * 3.0;

    feature1.push(f1);
    feature2.push(f2);
    feature3.push(f3);
    target.push(t);
}

let mut fanova = FanovaOptions::new()
    .random_forest(RandomForestOptions::new().seed(0))
    .fit(vec![&feature1, &feature2, &feature3], &target).unwrap();
let importances = (0..3)
    .map(|i| fanova.quantify_importance(&[i]).mean)
    .collect::<Vec<_>>();

assert_eq!(
    importances,
    vec![0.02744461966313835, 0.22991883769286145, 0.6288784011550144]
);

References

Dependencies

~2.3–3MB
~62K SLoC