Skip to content

Repository files navigation

FastML 0.1.0 [ALPHA-2026-08] β€” Classical Machine Learning & Pattern Recognition for Java

Status License: MIT Java Platform JitPack


⚑ 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);
    }
}

Table of Contents


Why FastML?

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.

Key Features

  • 🎯 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, binary RasterPattern, and custom numeric descriptors.

Performance

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

API Quick Reference

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.

Installation

Option 1: Maven (Recommended)

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>

Option 2: Gradle (via JitPack)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:FastML:0.1.0'
}

Technical Examples & Hero Demos

Case Java Example Description
Handwriting Recognition & Sliding Window HandwritingDemo.java Interactive GUI app demonstrating single-shot centroid learning and multi-region image scanning

Platform Support

Platform Status
Windows 10/11 βœ… Fully Supported
Linux βœ… Fully Supported
macOS βœ… Fully Supported

License

MIT License β€” See LICENSE for details.


Related Projects

  • 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. πŸš€

About

πŸ“Š Classical Machine Learning and Pattern Recognition library for Java β€” centroid learning, handwriting recognition, structural feature extraction, and sliding-window vision.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages