pub enum Error {
SingularMatrix,
InsufficientData {
required: usize,
available: usize,
},
InvalidInput(String),
DimensionMismatch(String),
ComputationFailed(String),
ParseError(String),
DomainCheck(String),
}Expand description
Error types for linear regression operations
§Example
let err = Error::InvalidInput("negative value".to_string());
assert!(err.to_string().contains("Invalid input"));Variants§
SingularMatrix
Matrix is singular (perfect multicollinearity).
This occurs when one or more predictor variables are linear combinations of others, making the matrix non-invertible. Remove redundant variables to resolve this error.
InsufficientData
Insufficient data points for the model.
OLS regression requires more observations than predictor variables.
Fields
InvalidInput(String)
Invalid input parameter.
Indicates that an input parameter has an invalid value (e.g., negative variance, empty data arrays, incompatible dimensions).
DimensionMismatch(String)
Dimension mismatch in matrix/vector operations.
This occurs when the dimensions of matrices or vectors are incompatible for the requested operation.
ComputationFailed(String)
Computation failed due to numerical issues.
This occurs when a numerical computation fails due to issues like singularity, non-convergence, or overflow/underflow.
ParseError(String)
Parse error for JSON/CSV data.
Raised when input data cannot be parsed as JSON or CSV.
DomainCheck(String)
Domain check failed (for WASM with domain restriction enabled).
By default, the WASM module allows all domains. This error is only returned
when the LINREG_DOMAIN_RESTRICT environment variable is set at build time
and the module is accessed from an unauthorized domain.
To enable domain restriction:
LINREG_DOMAIN_RESTRICT=example.com,yoursite.com wasm-pack build