ruthril 0.1.2

A powerful AI/ML framework is under development
Documentation
/// Base trait for all machine learning models in Ruthril
/// Provides a standard interface for model operations
use ruthril::core::statistics::Statistics;

pub trait Model {
    type Input;
    type Output;
    type Error;
    
    /// Train the model with provided data
    fn train(&mut self, data: &[Self::Input], targets: &[Self::Output]) -> Result<(), Self::Error>;
    
    /// Make predictions using the trained model
    fn predict(&self, input: &Self::Input) -> Result<Self::Output, Self::Error>;
    
    /// Validate model performance using statistics
    fn validate(&self, data: &[Self::Input], targets: &[Self::Output]) -> Result<f64, Self::Error>;
    
    /// Calculate model accuracy using Ruthril's statistics
    fn calculate_accuracy(&self, predictions: &[f64], targets: &[f64]) -> Option<f64> {
        if predictions.len() != targets.len() {
            return None;
        }
        
        let errors: Vec<f64> = predictions.iter()
            .zip(targets.iter())
            .map(|(pred, target)| (pred - target).abs())
            .collect();
        
        Statistics::mean(&errors)
    }
}