Skip to main content

Crate ferrolearn_core

Crate ferrolearn_core 

Source
Expand description

§ferrolearn-core

Core traits, error types, dataset abstractions, and pipeline infrastructure for the ferrolearn machine learning framework.

This crate defines the foundational abstractions that all other ferrolearn crates depend on:

  • Fit, Predict, Transform, FitTransform – the core ML traits with compile-time enforcement that predict() cannot be called on an unfitted model.
  • FerroError – the unified error type with rich diagnostic context.
  • Dataset – a trait for querying tabular data shape, with implementations for ndarray::Array2<f32> and ndarray::Array2<f64>.
  • pipeline::Pipeline – a dynamic-dispatch pipeline that composes transformers and a final estimator (requires std feature).
  • Introspection traitsHasCoefficients, HasFeatureImportances, HasClasses for inspecting fitted model internals.

§Features

  • std (default) – Enables std-dependent functionality (I/O errors, pipelines, std::error::Error impls).
  • faer (default) – Enables the NdarrayFaerBackend using the faer crate for pure-Rust linear algebra.
  • blas – Enables the BLASBackend using system BLAS/LAPACK via ndarray-linalg.

§Design Principles

§Compile-Time Safety (AC-3)

The unfitted configuration struct (e.g., LinearRegression) implements Fit but not Predict. Calling fit() returns a new fitted type (e.g., FittedLinearRegression) that implements Predict. Attempting to call predict() on an unfitted model is a compile error.

§Float Generics (REQ-15)

All algorithms are generic over F: num_traits::Float + Send + Sync + 'static.

§Error Handling

All public functions return Result<T, FerroError>. Library code never panics.

§Pluggable Backends (REQ-19)

The Backend trait abstracts linear algebra operations (SVD, QR, Cholesky, etc.), allowing algorithms to be generic over the backend implementation. The default backend NdarrayFaerBackend delegates to the faer crate.

Re-exports§

pub use backend::Backend;
pub use backend_faer::NdarrayFaerBackend;
pub use dataset::Dataset;
pub use error::FerroError;
pub use error::FerroResult;
pub use introspection::HasClasses;
pub use introspection::HasCoefficients;
pub use introspection::HasFeatureImportances;
pub use streaming::StreamingFitter;
pub use traits::Fit;
pub use traits::FitTransform;
pub use traits::PartialFit;
pub use traits::Predict;
pub use traits::Transform;

Modules§

backend
Pluggable backend trait for linear algebra operations.
backend_faer
Default backend implementation using faer for linear algebra.
dataset
Dataset trait and implementations for common array types.
error
Error types for the ferrolearn framework.
introspection
Introspection traits for fitted models.
pipeline
Dynamic-dispatch pipeline for composing transformers and estimators.
streaming
Streaming data adapter for incremental learning.
traits
Core ML traits for the ferrolearn framework.
typed_pipeline
Compile-time type-safe pipeline using recursive tuple types.

Type Aliases§

DefaultBackend
The default linear algebra backend.