β‘ Small, deterministic, low-overhead Machine Learning algorithms, pattern matching, and feature extraction for the FastJava ecosystem.
FastML is the classical Machine Learning toolbox of the FastJava ecosystem. While FastModel and FastAI focus on large language models (LLMs) and neural embeddings, FastML delivers lightweight, zero-bloat primitives for pattern recognition, centroid learning, classification, clustering, and structural vision feature extraction.
// Quick Start β Example
import fastml.FastML;
import fastml.algorithm.CentroidClassifier;
import fastml.pattern.Pattern;
public class Demo {
public static void main(String[] args) {
CentroidClassifier<Character> model = FastML.centroid();
// 1. Train raster pattern for letter 'A'
Pattern patternA = FastML.raster("""
0 0 1 1 1 0 0
0 1 0 0 0 1 0
1 0 0 0 0 0 1
1 1 1 1 1 1 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
""");
model.train('A', patternA);
// 2. Predict character from input pattern
char prediction = model.predict(patternA);
System.out.println("Predicted: " + prediction);
}
}- Why FastML?
- Key Features
- Performance
- API Quick Reference
- Installation
- Technical Examples & Hero Demos
- Documentation
- Platform Support
- License
- Related Projects
Modern AI runtimes frequently force heavy Python dependencies, multi-gigabyte models, and high memory footprints even for trivial deterministic tasks like handwriting detection, gesture recognition, or pattern classification.
FastML provides:
- 100% Pure JVM Execution β Zero external C/Python dependencies, small footprint, fast boot time.
- Deterministic & Trainable β Simple mathematical models (Nearest Centroid, Geometric Invariant Features) with predictable output and low latency.
- Incremental & Online Learning β Learn from single samples on the fly without heavy retraining pipelines.
- Sub-Millisecond Inference β Highly optimized feature vectors and compact primitive array storage.
- π― Centroid & Nearest-Mean Classifier β Fast online vector averaging and Euclidean distance prediction.
- π Structural & Geometric Feature Extraction β 8D normalized feature extractor for handwriting, characters, and image patches (aspect ratio, center of mass, stroke density, segment lengths).
- πͺ Sliding Window Vision Scanner β Multi-scale image scanning engine to locate and classify pattern matches across target images.
- π§© Flexible Pattern Abstraction β First-class support for
VectorPattern, binaryRasterPattern, and custom numeric descriptors.
| Operation | Scale / Input | Time / Latency |
|---|---|---|
| Feature Extraction (8D) | 60Γ60 Image Window | < 40 Β΅s |
| Centroid Distance Match | 8-Dimensional Vector | < 15 ns |
| Sliding Window Scan | 800Γ600 Image (15px Stride) | ~18 ms |
| Method | Description |
|---|---|
FastML.centroid() |
Creates a new CentroidClassifier instance. |
FastML.vector(double...) |
Creates a numeric VectorPattern. |
FastML.raster(String) |
Parses a multiline ASCII grid into a RasterPattern. |
FastML.extractFeatures(img, x, y, w, h) |
Extracts an 8D normalized feature vector from a sub-rectangle. |
FastML.scanner(classifier) |
Creates a SlidingWindowScanner for image object detection. |
Add the JitPack repository and dependency to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastML</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastML:0.1.0'
}| Case | Java Example | Description |
|---|---|---|
| Handwriting Recognition & Sliding Window | HandwritingDemo.java | Interactive GUI app demonstrating single-shot centroid learning and multi-region image scanning |
| Platform | Status |
|---|---|
| Windows 10/11 | β Fully Supported |
| Linux | β Fully Supported |
| macOS | β Fully Supported |
MIT License β See LICENSE for details.
- FastAI β High-level unified AI client
- FastModel β Local GGUF/ONNX model runtimes
- FastAIVectorDB β High-speed native vector database
- FastMath β SIMD and matrix math primitives
- FastCore β Native JNI loader and utilities
Part of the FastJava Ecosystem β Making the JVM faster. Small package. Maximum speed. Zero bloat. π