pub struct RuleMiner { /* private fields */ }Expand description
Main rule mining engine
Implementations§
Source§impl RuleMiner
impl RuleMiner
Sourcepub fn new(config: MiningConfig) -> Self
pub fn new(config: MiningConfig) -> Self
Create new rule miner with config
Sourcepub fn add_transactions(&mut self, transactions: Vec<Transaction>) -> Result<()>
pub fn add_transactions(&mut self, transactions: Vec<Transaction>) -> Result<()>
Add transactions to mine
Sourcepub fn add_transaction(&mut self, transaction: Transaction) -> Result<()>
pub fn add_transaction(&mut self, transaction: Transaction) -> Result<()>
Add transactions from an iterator (streaming support)
This method allows adding transactions one-by-one from a stream, maintaining constant memory usage for the loading phase.
§Example
use rust_rule_miner::{RuleMiner, MiningConfig, data_loader::DataLoader, Transaction};
use chrono::Utc;
let mut miner = RuleMiner::new(MiningConfig::default());
// Add transactions one by one
let transaction = Transaction::new("tx1".to_string(), vec!["A".to_string()], Utc::now());
miner.add_transaction(transaction)?;
let rules = miner.mine_association_rules()?;Sourcepub fn add_transactions_from_iter<I>(&mut self, iter: I) -> Result<()>
pub fn add_transactions_from_iter<I>(&mut self, iter: I) -> Result<()>
Add transactions from an iterator (batch streaming)
More efficient than add_transaction() when you have an iterator.
§Example
use rust_rule_miner::{RuleMiner, MiningConfig, data_loader::{DataLoader, ColumnMapping}};
let mut miner = RuleMiner::new(MiningConfig::default());
// Load from CSV and add to miner
let mapping = ColumnMapping::simple(0, 1, 2);
let transactions = DataLoader::from_csv("file.csv", mapping)?;
miner.add_transactions_from_iter(transactions.into_iter().map(Ok))?;
let rules = miner.mine_association_rules()?;Sourcepub fn transaction_count(&self) -> usize
pub fn transaction_count(&self) -> usize
Get transaction count
Sourcepub fn mine_association_rules(&mut self) -> Result<Vec<AssociationRule>>
pub fn mine_association_rules(&mut self) -> Result<Vec<AssociationRule>>
Mine association rules using configured algorithm
Sourcepub fn stats(&self) -> &MiningStats
pub fn stats(&self) -> &MiningStats
Get mining statistics
Auto Trait Implementations§
impl Freeze for RuleMiner
impl RefUnwindSafe for RuleMiner
impl Send for RuleMiner
impl Sync for RuleMiner
impl Unpin for RuleMiner
impl UnwindSafe for RuleMiner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.