1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! FormicaX - High-Performance Clustering Library for Financial Data Analysis
//!
//! FormicaX is a high-performance Rust library designed specifically for clustering analysis
//! of financial data. It implements advanced machine learning clustering algorithms optimized
//! for OHLCV (Open, High, Low, Close, Volume) data to identify market patterns, regimes, and trading opportunities.
//!
//! # Quick Start
//!
//! ```rust
//! use formica::{
//! clustering::kmeans::algorithm::KMeans,
//! clustering::kmeans::config::{KMeansConfig, KMeansVariant},
//! core::{ClusteringAlgorithm, OHLCV},
//! };
//! use chrono::Utc;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create sample OHLCV data
//! let ohlcv_data = vec![
//! OHLCV::new(Utc::now(), 100.0, 105.0, 98.0, 102.0, 1000),
//! OHLCV::new(Utc::now(), 102.0, 107.0, 100.0, 104.0, 1200),
//! OHLCV::new(Utc::now(), 104.0, 109.0, 102.0, 106.0, 1100),
//! ];
//!
//! // Configure K-Means with modern builder pattern
//! let config = KMeansConfig::builder()
//! .k(2) // 2 clusters
//! .variant(KMeansVariant::Lloyd) // Use Lloyd's algorithm
//! .max_iterations(100) // Maximum iterations
//! .parallel(false) // Disable parallel for small dataset
//! .build()?;
//!
//! // Initialize and fit the clustering algorithm
//! let mut kmeans = KMeans::with_config(config);
//! let result = kmeans.fit(&ohlcv_data)?;
//!
//! // Display comprehensive results
//! println!("Clustering completed successfully!");
//! println!("- Algorithm: {}", result.algorithm_name);
//! println!("- Clusters: {}", result.n_clusters);
//! println!("- Iterations: {}", result.iterations);
//! println!("- Converged: {}", result.converged);
//! println!("- Silhouette Score: {:.3}", result.silhouette_score);
//! println!("- Execution Time: {:?}", result.execution_time);
//!
//! Ok(())
//! }
//! ```
// Core modules
// Re-export main types for convenience
pub use ;
// The following are commented out until implemented:
// pub use clustering::{
// KMeans,
// KMeansConfig,
// KMeansVariant,
// DBSCAN,
// DBSCANConfig,
// DBSCANVariant,
// GMM,
// GMMConfig,
// Hierarchical,
// HierarchicalConfig,
// AffinityPropagation,
// AffinityPropagationConfig,
// SOM,
// SOMConfig,
// };
//
// pub use analysis::{
// ClusterAnalyzer,
// Predictor,
// ValidationMetrics,
// };
//
// pub use core::traits::*;
// pub use clustering::common::*;
// Version information
pub const VERSION: &str = env!;
pub const AUTHORS: &str = env!;
pub const DESCRIPTION: &str = env!;