Skip to main content

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("Model build error: {0}")]
13    BuildError(String),
14    #[error("Linear algebra")]
15    LinalgError {
16        #[from]
17        source: LinalgError,
18    },
19    #[error("Underconstrained data")]
20    Underconstrained,
21    #[error("Colinear data (X^T * X is not invertible)")]
22    ColinearData,
23    #[error("Maximum iterations ({0}) reached")]
24    MaxIter(usize),
25}
26
27pub type RegressionResult<T> = Result<T, RegressionError>;