linfa_elasticnet/
error.rs

1#[cfg(feature = "serde")]
2use serde_crate::{Deserialize, Serialize};
3use thiserror::Error;
4
5/// Simplified `Result` using [`ElasticNetError`](crate::ElasticNetError) as error type
6pub type Result<T> = std::result::Result<T, ElasticNetError>;
7
8#[cfg_attr(
9    feature = "serde",
10    derive(Serialize, Deserialize),
11    serde(crate = "serde_crate")
12)]
13/// Error variants from hyperparameter construction or model estimation
14#[derive(Debug, Clone, Error)]
15pub enum ElasticNetError {
16    /// The input has not enough samples
17    #[error("not enough samples as they have to be larger than number of features")]
18    NotEnoughSamples,
19    /// The input is singular
20    #[error("the data is ill-conditioned")]
21    IllConditioned,
22    #[error("l1 ratio should be in range [0, 1], but is {0}")]
23    InvalidL1Ratio(f32),
24    #[error("invalid penalty {0}")]
25    InvalidPenalty(f32),
26    #[error("invalid tolerance {0}")]
27    InvalidTolerance(f32),
28    #[error("the target can either be a vector (ndim=1) or a matrix (ndim=2)")]
29    IncorrectTargetShape,
30    #[error(transparent)]
31    BaseCrate(#[from] linfa::Error),
32}