项目作者: JmPotato

项目描述 :
An implementation of the FP-Growth algorithm in pure Rust.
高级语言: Rust
项目地址: git://github.com/JmPotato/fp-growth-rs.git
创建时间: 2021-03-25T16:37:20Z
项目社区:https://github.com/JmPotato/fp-growth-rs

开源协议:MIT License

下载


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:

  1. [dependencies]
  2. fp-growth = "0.1"

Example

  1. use fp_growth::algorithm::FPGrowth;
  2. fn main() {
  3. let transactions = vec![
  4. vec!["e", "c", "a", "b", "f", "h"],
  5. vec!["a", "c", "g"],
  6. vec!["e"],
  7. vec!["e", "c", "a", "g", "d"],
  8. vec!["a", "c", "e", "g"],
  9. vec!["e"],
  10. vec!["a", "c", "e", "b", "f"],
  11. vec!["a", "c", "d"],
  12. vec!["g", "c", "e", "a"],
  13. vec!["a", "c", "e", "g"],
  14. vec!["i"],
  15. ];
  16. let minimum_support = 2;
  17. let fp_growth_str = FPGrowth::<&str>::new(transactions, minimum_support);
  18. let result = fp_growth_str.find_frequent_patterns();
  19. println!("The number of results: {}", result.frequent_patterns_num());
  20. for (frequent_pattern, support) in result.frequent_patterns().iter() {
  21. println!("{:?} {}", frequent_pattern, support);
  22. }
  23. }

License

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

See LICENSE for details.