Expand description
§K-modes and K-prototypes Clustering
This crate provides implementations of the k-modes and k-prototypes clustering algorithms for categorical and mixed (categorical + numerical) data.
§Features
- K-modes: Clustering for purely categorical data
- K-prototypes: Clustering for mixed categorical and numerical data
- Multiple initialization strategies (Huang, Cao, random)
- Parallel processing support via Rayon
- Comprehensive distance metrics for categorical data
§Example
use kategorize::{KModes, InitMethod};
use ndarray::Array2;
// Create sample categorical data
let data = Array2::from_shape_vec((4, 2), vec![
"A", "X", "A", "Y", "B", "X", "B", "Y"
]).unwrap();
// Create k-modes clusterer
let mut kmodes = KModes::new(2)
.init_method(InitMethod::Huang)
.max_iter(100)
.n_init(10);
// Fit the model and get cluster assignments
let result = kmodes.fit(data.view()).unwrap();
println!("Cluster labels: {:?}", result.labels);
Re-exports§
pub use error::Error;
pub use error::Result;
pub use kmodes::KModes;
pub use kmodes::KModesResult;
pub use kprototypes::KPrototypes;
pub use kprototypes::KPrototypesResult;
pub use kprototypes::MixedValue;
pub use initialization::InitMethod;
Modules§
- distance
- Distance metrics for categorical and mixed data
- error
- Error types for the k-modes crate
- initialization
- Initialization methods for k-modes and k-prototypes clustering
- kmodes
- K-modes clustering algorithm implementation
- kprototypes
- K-prototypes clustering algorithm for mixed categorical and numerical data
- utils
- Utility functions for k-modes clustering
Type Aliases§
- Array1
- Re-export commonly used types from ndarray one-dimensional array
- Array2
- Re-export commonly used types from ndarray two-dimensional array
- Array
View1 - Re-export commonly used types from ndarray one-dimensional array view
- Array
View2 - Re-export commonly used types from ndarray two-dimensional array view