linfa_logistic/
error.rs

1use thiserror::Error;
2pub type Result<T> = std::result::Result<T, Error>;
3
4#[derive(Error, Debug)]
5pub enum Error {
6    #[error(transparent)]
7    LinfaError(#[from] linfa::Error),
8    #[error("More than two classes for logistic regression")]
9    TooManyClasses,
10    #[error("Fewer than two classes for logistic regression")]
11    TooFewClasses,
12    #[error(transparent)]
13    ArgMinError(#[from] argmin::core::Error),
14    #[error("Expected `x` and `y` to have same number of rows, got {0} != {1}")]
15    MismatchedShapes(usize, usize),
16    #[error("Values must be finite and not `Inf`, `-Inf` or `NaN`")]
17    InvalidValues,
18    #[error("Rows of initial parameter ({rows}) must be the same as the number of features ({n_features})")]
19    InitialParameterFeaturesMismatch { rows: usize, n_features: usize },
20    #[error("Columns of initial parameter ({cols}) must be the same as the number of classes ({n_classes})")]
21    InitialParameterClassesMismatch { cols: usize, n_classes: usize },
22
23    #[error("gradient_tolerance must be a positive, finite number")]
24    InvalidGradientTolerance,
25    #[error("alpha must be a positive, finite number")]
26    InvalidAlpha,
27    #[error("Initial parameters must be finite")]
28    InvalidInitialParameters,
29}