pub enum Error {
SingularMatrix,
InsufficientData {
required: usize,
available: usize,
},
InvalidInput(String),
DimensionMismatch(String),
ComputationFailed(String),
ParseError(String),
DomainCheck(String),
IoError(String),
SerializationError(String),
DeserializationError(String),
IncompatibleFormatVersion {
file_version: String,
supported: String,
},
ModelTypeMismatch {
expected: String,
found: 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 buildIoError(String)
File I/O error during model save/load operations.
Raised when reading or writing model files fails due to permissions, missing files, or other I/O issues.
SerializationError(String)
Serialization error when converting model to JSON.
Raised when a model cannot be serialized to JSON format.
DeserializationError(String)
Deserialization error when parsing model from JSON.
Raised when a JSON file cannot be parsed into a model structure.
IncompatibleFormatVersion
Incompatible format version when loading a model.
Raised when the format version of a saved model is not compatible with the current library version.
Fields
ModelTypeMismatch
Model type mismatch when loading a model.
Raised when attempting to load a model as the wrong type (e.g., loading an OLS model as Ridge).