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
113
114
115
116
//! Tiny Model Representation (spec ยง4.3)
//!
//! Specialized representations for small models (< 1 MB) that minimize
//! overhead while preserving full functionality. Designed for:
//! - Educational examples
//! - Edge deployment
//! - WASM playgrounds
//! - Embedded systems
//!
//! # Model Types
//! - **Linear**: Coefficients + intercept (< 1 KB typical)
//! - **Stump**: Single decision split (< 100 bytes)
//! - **`NaiveBayes`**: Means + variances per class (< 10 KB typical)
//! - **`KMeans`**: Cluster centroids (< 100 KB typical)
//! - **Compressed**: Larger models with compression
use DataCompression;
/// Compact representation for tiny models (educational/edge deployment)
///
/// Provides specialized storage for common small model architectures,
/// avoiding the overhead of generic serialization formats.
///
/// # Example
/// ```
/// use aprender::embed::TinyModelRepr;
///
/// // Linear model with 10 features
/// let linear = TinyModelRepr::linear(
/// vec![0.5, -0.3, 0.8, 0.2, -0.1, 0.4, -0.6, 0.9, 0.1, -0.4],
/// 1.5,
/// );
/// assert_eq!(linear.size_bytes(), 44); // 10 * 4 + 4
///
/// // Decision stump
/// let stump = TinyModelRepr::stump(3, 0.5, -1.0, 1.0);
/// assert_eq!(stump.size_bytes(), 14); // 2 + 4 + 4 + 4
///
/// // K-Means with 3 clusters, 2 features each
/// let kmeans = TinyModelRepr::kmeans(vec![
/// vec![1.0, 2.0],
/// vec![4.0, 5.0],
/// vec![7.0, 8.0],
/// ]);
/// assert_eq!(kmeans.size_bytes(), 24); // 3 * 2 * 4
/// ```
include!;
include!;
include!;