use thiserror::Error;
#[derive(Error, Debug)]
pub enum KMeansParamsError {
#[error("n_clusters cannot be 0")]
NClusters,
#[error("n_runs cannot be 0")]
NRuns,
#[error("tolerance must be greater than 0")]
Tolerance,
#[error("max_n_iterations cannot be 0")]
MaxIterations,
}
#[derive(Error, Debug)]
pub enum KMeansError {
#[error("Invalid hyperparameter: {0}")]
InvalidParams(#[from] KMeansParamsError),
#[error("Fitting failed: No inertia improvement (-inf)")]
InertiaError,
#[error(transparent)]
LinfaError(#[from] linfa::error::Error),
}
#[derive(Error, Debug)]
pub enum IncrKMeansError<M: std::fmt::Debug> {
#[error("Invalid hyperparameter: {0}")]
InvalidParams(#[from] KMeansParamsError),
#[error("Algorithm has not yet converged, Keep on running the algorithm.")]
NotConverged(M),
#[error(transparent)]
LinfaError(#[from] linfa::error::Error),
}