1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
use ndarray_stats::errors::MinMaxError;
use thiserror::Error;

/// Simplified `Result` using [`NaiveBayesError`](crate::NaiveBayesError) as error type
pub type Result<T> = std::result::Result<T, NaiveBayesError>;

/// Error variants from hyper-parameter construction or model estimation
#[derive(Error, Debug)]
pub enum NaiveBayesError {
    /// Error when performing Max operation on data
    #[error("invalid statistical operation {0}")]
    Stats(#[from] MinMaxError),
    /// Invalid smoothing parameter
    #[error("invalid smoothing parameter {0}")]
    InvalidSmoothing(f64),
    #[error(transparent)]
    BaseCrate(#[from] linfa::Error),
}