Skip to main content
MLPP follows a modular, header-only design that emphasizes clarity, efficiency, and extensibility. The library provides classical machine learning algorithms with transparent implementations and predictable performance characteristics.

Minimal-dependency philosophy

The codebase is built on a minimal-dependency philosophy, relying primarily on the C++ standard library and a focused set of self-contained headers. This design choice ensures:
  • Portability: Minimal external requirements make integration straightforward
  • Transparency: Clear dependency boundaries and predictable compilation
  • Control: Users can opt into dependencies based on their specific needs

Core dependencies

MLPP requires only C++20 and optionally integrates with:
  • Eigen 3.4+: Linear algebra operations (recommended)
  • Python3 + NumPy: Visualization support via matplotlib
  • OpenCV: Computer vision integration
All optional dependencies are controlled through CMake options and compile-time definitions.

Header-only architecture

MLPP is structured as an interface library, meaning all functionality is provided through headers without requiring compilation of library binaries.
add_library(mlpp INTERFACE)
add_library(mlpp::mlpp ALIAS mlpp)

target_include_directories(mlpp INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)

target_compile_features(mlpp INTERFACE cxx_std_20)

Benefits of header-only design

Users include headers directly without building separate library binaries. This simplifies integration and eliminates ABI compatibility concerns.
Header-only design naturally supports generic programming with templates, enabling compile-time optimizations across the entire codebase.
Projects can include MLPP by adding a single include directory, making it trivial to integrate into existing build systems.

Module organization

The library is organized into logical modules, each exposing a concise interface:
#pragma once

#include "defines.hpp"

// Model Validation
#include "Model Validation/confusion_matrix.h"
#include "Model Validation/metrics.h"

// Supervised Learning
#include "Supervised Learning/Classifiers/LDA.h"
#include "Supervised Learning/Classifiers/logistic_regression.h"
#include "Supervised Learning/Regression/linear_regression.hpp"
#include "Supervised Learning/Decision Trees/decision_tree.h"

// Unsupervised Learning
#include "Unsupervised Learning/Clustering/clustering_dataset.hpp"
#include "Unsupervised Learning/Dimensionality Reduction/PCA.h"
#include "Unsupervised Learning/Dimensionality Reduction/SVD.h"
Each module can be included independently or through the unified mlpp.h header.

Type system

MLPP defines a consistent type system across all modules:
#define INTEGER int
#define BIGINTEGER long
#define REAL double

#define MIN_INTEGER std::numeric_limits<INTEGER>::min()
#define MAX_INTEGER std::numeric_limits<INTEGER>::max()
#define MIN_REAL -std::numeric_limits<REAL>::max()
#define MAX_REAL std::numeric_limits<REAL>::max()
This abstraction layer provides:
  • Consistency: Uniform numeric types across the library
  • Flexibility: Easy to change precision requirements globally
  • Clarity: Explicit semantic meaning for numeric types

Design principles

Mathematical explicitness

Implementations closely follow mathematical formulations, making algorithms transparent and verifiable.

Predictable performance

Operations have clear complexity characteristics documented in code comments.

Independent modules

Each algorithm operates independently with minimal coupling between components.

Modern C++

Leverages C++20 features including concepts, ranges, and improved template metaprogramming.

Compile-time configuration

MLPP uses preprocessor definitions to enable optional features:
  • MLPP_HAS_EIGEN: Eigen integration available
  • MLPP_WITH_PYPLOT: Matplotlib visualization enabled
  • MLPP_HAS_OPENCV: OpenCV support compiled in
These definitions are automatically set by the CMake build system based on available dependencies.

Build docs developers (and LLMs) love