Crate iron_learn

Crate iron_learn 

Source
Expand description

§Iron Learn - A Rust Machine Learning Library

A pure Rust, type-safe machine learning library in pure Rust with GPU acceleration. Provides tensor operations, gradient-based optimization, and support for complex-valued computations.

§Key Features

  • GPU-Accelerated Training: CUDA kernels for efficient large-scale optimization
  • Type Safety: All operations return Result types; no unwrap-induced panics
  • Zero-Copy Borrowing: Compute without unnecessary allocations
  • Generic Numerics: Works with f64, f32, i32, i64, Complex, and custom types
  • Automatic Preprocessing: Feature normalization and bias handling built-in

§Modules

  • tensor: Core multi-dimensional array operations
  • complex: Complex number arithmetic
  • numeric: Generic type system for computations
  • gradient_descent: CPU optimization algorithms
  • gpu_regression: CUDA-accelerated training
  • regression: High-level training interface
  • app_context: Global application state

§Quick Example

use iron_learn::{Tensor, linear_regression};

let x = Tensor::new(vec![10, 3], vec![/* data */])?;
let y = Tensor::new(vec![10, 1], vec![/* labels */])?;
let mut w = Tensor::new(vec![4, 1], vec![0.0; 4])?;

for _ in 0..1000 {
    w = linear_regression(&x, &y, &w, 0.01)?;
}

§Version

0.5.0 - GPU-Accelerated Release

Structs§

AppContext
Global application context with training configuration and GPU capabilities
Complex
A complex number represented by real and imaginary components
Data
Container for complete dataset with both linear and logistic regression splits
Tensor
The Tensor structure is the cornerstone of this library, providing a comprehensive suite of mathematical operations for the manipulation of multidimensional data.
XY
Training and test data container for regression tasks

Statics§

GLOBAL_CONTEXT
Global singleton instance of application context

Traits§

Numeric
The Numeric trait defines a set of operations that numeric types must support. It includes basic arithmetic operations and the ability to return special values like zero and one.

Functions§

gradient_descent
Core gradient descent optimization algorithm
init_context
Initialize the global application context
linear_regression
Linear regression with automatic preprocessing
logistic_regression
Logistic regression with automatic preprocessing
predict_linear
Prediction function for linear regression
predict_logistic
Prediction function for logistic regression
run_linear
Trains and evaluates linear regression model
run_logistic
Trains and evaluates logistic regression model
run_logistics_cuda
Main GPU training function for logistic regression Implements gradient descent using CUDA kernels for efficient computation Returns accuracy metrics on test set upon completion