linfa_clustering/k_means/
errors.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum KMeansParamsError {
6 #[error("n_clusters cannot be 0")]
7 NClusters,
8 #[error("n_runs cannot be 0")]
9 NRuns,
10 #[error("tolerance must be greater than 0")]
11 Tolerance,
12 #[error("max_n_iterations cannot be 0")]
13 MaxIterations,
14}
15
16#[derive(Error, Debug)]
18pub enum KMeansError {
19 #[error("Invalid hyperparameter: {0}")]
21 InvalidParams(#[from] KMeansParamsError),
22 #[error("Fitting failed: No inertia improvement (-inf)")]
24 InertiaError,
25 #[error(transparent)]
26 LinfaError(#[from] linfa::error::Error),
27}
28
29#[derive(Error, Debug)]
30pub enum IncrKMeansError<M: std::fmt::Debug> {
31 #[error("Invalid hyperparameter: {0}")]
33 InvalidParams(#[from] KMeansParamsError),
34 #[error("Algorithm has not yet converged, Keep on running the algorithm.")]
37 NotConverged(M),
38 #[error(transparent)]
39 LinfaError(#[from] linfa::error::Error),
40}