rust_rule_miner/
config.rs

1use serde::{Deserialize, Serialize};
2use std::time::Duration;
3
4/// Mining configuration
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct MiningConfig {
7    /// Minimum support threshold (0.0 - 1.0)
8    /// Example: 0.1 = pattern must appear in at least 10% of transactions
9    pub min_support: f64,
10
11    /// Minimum confidence threshold (0.0 - 1.0)
12    /// Example: 0.7 = rule must be correct at least 70% of the time
13    pub min_confidence: f64,
14
15    /// Minimum lift threshold
16    /// Example: 1.2 = items must co-occur 20% more than random chance
17    pub min_lift: f64,
18
19    /// Maximum time gap for sequential patterns
20    pub max_time_gap: Option<Duration>,
21
22    /// Mining algorithm to use
23    pub algorithm: MiningAlgorithm,
24}
25
26impl Default for MiningConfig {
27    fn default() -> Self {
28        Self {
29            min_support: 0.1,    // 10%
30            min_confidence: 0.7, // 70%
31            min_lift: 1.0,       // No negative correlation
32            max_time_gap: None,
33            algorithm: MiningAlgorithm::Apriori,
34        }
35    }
36}
37
38#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
39pub enum MiningAlgorithm {
40    /// Apriori algorithm (classic, easy to understand)
41    Apriori,
42
43    /// FP-Growth (faster, more memory efficient for dense datasets)
44    FPGrowth,
45
46    /// Eclat (uses vertical data format)
47    #[allow(dead_code)]
48    Eclat,
49}