fastkmeans_rs/error.rs
1use thiserror::Error;
2
3/// Error types for the FastKMeans library
4#[derive(Error, Debug)]
5pub enum KMeansError {
6 /// The number of clusters k is invalid (must be > 0)
7 #[error("Invalid k value: {0}")]
8 InvalidK(String),
9
10 /// Not enough data points for the requested number of clusters
11 #[error("Insufficient data: {0}")]
12 InsufficientData(String),
13
14 /// Model has not been fitted yet
15 #[error("Model has not been fitted. Call train() or fit() first.")]
16 NotFitted,
17
18 /// Dimension mismatch between data and model
19 #[error("Dimension mismatch: {0}")]
20 InvalidDimensions(String),
21}