Overview
tinycml is a minimal, pure C11 machine learning library with zero external dependencies. Neural networks, grid search, preprocessing β all under 12K LOC.
Designed for resource-constrained environments where pulling in Python or C++ dependencies isnβt an option.
Features
- Neural Networks β Feedforward networks with configurable layers, activations (sigmoid, tanh, ReLU), and training via backpropagation
- Grid Search β Generic k-fold cross-validation with hyperparameter tuning (qsort-based)
- Preprocessing β Normalization, standardization, train-test split
- Metrics β Accuracy, precision, recall, F1-score, confusion matrix
- Zero Dependencies β Pure C11, no external libs, no dynamic allocation leaks
- Thread-safe β No global state, all state passed via struct pointers
Architecture
tinycml/
βββ cml_matrix.h β Matrix operations (transpose, multiply, inverse)
βββ cml_nn.h β Neural network (forward, backprop, train, predict)
βββ cml_preprocess.h β Normalization, standardization, splitting
βββ cml_metrics.h β Classification metrics
βββ cml_grid.h β Grid search with k-fold CV
βββ cml.h β Umbrella include header
βββ examples/ β Usage examples
Status
Active development. Phase 1 (core API, NN, grid search) is complete. Phase 2 (tests + CI) and Phase 3 (performance optimizations) are in progress.