#data-mining #pure #algorithm #growth #fp

fp-growth

An implementation of the FP-Growth algorithm in pure Rust

5 releases

0.1.6 Apr 20, 2021
0.1.4 Apr 2, 2021
0.1.2 Mar 30, 2021

#1341 in Algorithms

Download history 7/week @ 2024-07-20 9/week @ 2024-07-27 2/week @ 2024-08-03 1/week @ 2024-08-10 2/week @ 2024-08-31 16/week @ 2024-09-07 42/week @ 2024-09-14 55/week @ 2024-09-21 42/week @ 2024-09-28 40/week @ 2024-10-05 17/week @ 2024-10-12 6/week @ 2024-10-19 11/week @ 2024-10-26 17/week @ 2024-11-02

53 downloads per month

Custom license

27KB
502 lines

fp-growth-rs

Crates.io docs.rs

An implementation of the FP-Growth algorithm in pure Rust, which is inspired by enaeseth/python-fp-growth.

Usage

Add this to your Cargo.toml:

[dependencies]
fp-growth = "0.1"

Example

use fp_growth::algorithm::FPGrowth;

fn main() {
    let transactions = vec![
        vec!["e", "c", "a", "b", "f", "h"],
        vec!["a", "c", "g"],
        vec!["e"],
        vec!["e", "c", "a", "g", "d"],
        vec!["a", "c", "e", "g"],
        vec!["e"],
        vec!["a", "c", "e", "b", "f"],
        vec!["a", "c", "d"],
        vec!["g", "c", "e", "a"],
        vec!["a", "c", "e", "g"],
        vec!["i"],
    ];
    let minimum_support = 2;
    let fp_growth_str = FPGrowth::<&str>::new(transactions, minimum_support);

    let result = fp_growth_str.find_frequent_patterns();
    println!("The number of results: {}", result.frequent_patterns_num());
    for (frequent_pattern, support) in result.frequent_patterns().iter() {
        println!("{:?} {}", frequent_pattern, support);
    }
}

License

fp-growth-rs is distributed under the terms of the MIT license.

See LICENSE for details.

No runtime deps