1 unstable release
| 0.1.0-alpha.1 | Sep 30, 2025 |
|---|
#2831 in Algorithms
3.5MB
73K
SLoC
Unsupervised learning and clustering algorithms for ToRSh
This crate provides PyTorch-compatible clustering algorithms built on top of the SciRS2 ecosystem, offering high-performance implementations of popular clustering methods with extensive customization options.
Key Features
- K-Means Clustering: Classic centroid-based clustering with multiple initialization strategies
- Hierarchical Clustering: Agglomerative and divisive clustering methods
- DBSCAN: Density-based clustering for arbitrary-shaped clusters
- Gaussian Mixture Models: Probabilistic clustering with EM algorithm
- Spectral Clustering: Graph-based clustering using eigendecomposition
- Evaluation Metrics: Silhouette score, adjusted rand index, and more
SciRS2 Integration
All clustering algorithms are built on scirs2-cluster foundation:
- Leverages scirs2-core for random number generation and array operations
- Uses scirs2-stats for statistical computations
- Integrates with scirs2-metrics for clustering evaluation
- Employs scirs2-linalg for linear algebra operations
Example Usage
use torsh_cluster::prelude::*;
use torsh_tensor::Tensor;
// Create sample data
let data = Tensor::randn(&[100, 2])?;
// Perform K-means clustering
let kmeans = KMeans::new(3)
.max_iters(100)
.tolerance(1e-4);
let result = kmeans.fit(&data)?;
println!("Cluster centers: {:?}", result.centroids);
println!("Labels: {:?}", result.labels);
Dependencies
~142MB
~2M SLoC