ndarray_glm/
error.rs

1//! define the error enum for the result of regressions
2
3use ndarray_linalg::error::LinalgError;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum RegressionError {
8    #[error("Inconsistent input: {0}")]
9    BadInput(String),
10    #[error("Invalid response data: {0}")]
11    InvalidY(String),
12    #[error("Linear algebra")]
13    LinalgError {
14        #[from]
15        source: LinalgError,
16    },
17    #[error("Underconstrained data")]
18    Underconstrained,
19    #[error("Colinear data (X^T * X is not invertible)")]
20    ColinearData,
21    #[error("Maximum iterations ({0}) reached")]
22    MaxIter(usize),
23}
24
25pub type RegressionResult<T> = Result<T, RegressionError>;