MCPcopy Index your code
hub / github.com/daniel-e/rustml

github.com/daniel-e/rustml @0.0.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.0.5 ↗ · + Follow
439 symbols 1,082 edges 44 files 172 documented · 39% updated 4y ago0.0.5 · 2015-10-07★ 692 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Rustml

Rustml is a library for doing machine learning in Rust.

The documentation of the project with a descprition of the modules can be found here.

Features

  • powerful matrix and vector support with BLAS bindings to provide very high performance
  • k-nearest neighbord classification algorithm
  • DBSCAN clustering algorithm
  • gradient descent for minimizing functions
  • linear regression
  • easy access to MNIST database of handwritten digits via an the rustml dataset package
  • parse and create CSV files
  • statistical functions like mean and variance for vectors and matrices
  • reading gzip compressed files
  • distance metrics
  • OpenCV binding to read images and videos plus interfaces for simplify feature extraction from images and videos (e.g. select pixels from images or frames of a video via a mask)
  • scaling of feature vectors and matrices
  • multidimensional sliding windows
  • examples

Using rustml from scratch - example matrix multplication

Create a new project with cargo:

cargo new example --bin

A new directory example is created. Change into this directory and add the following lines Cargo.toml:

[dependencies.rustml]
git = "https://github.com/daniel-e/rustml/"

or the following dependency:

[dependencies]
rustml = "*"

Edit the file main.rs in the src directory.

#[macro_use] extern crate rustml;

use rustml::*;

fn main() {
    let a = mat![
        1.0f32, 2.0;
        3.0, 4.0;
        5.0, 6.0
    ];
    let b = mat![
        5.0, 7.0;
        6.0, 2.0
    ];
    let c = (a * b).unwrap();

    println!("{}", c);
}

Now, in the example directory run the example with cargo run.

Other examples

You can find other examples in the directory examples. These examples can be executed with Cargo as follows:

cargo run --example vector_addition
cargo run --example matrix_multiplication
cargo run --example scale_matrix

# the following examples require the rustml dataset package (see below)
cargo run --example video_histogram
cargo run --example mnist_digits

Rustml datasets package

The rustml dataset package needs to be installed separately. The package currently contains the MNIST database of handwritten digits and videos for the examples. Download the following script which will download and install the package in your home in the directory ~/.rustml/.

# download the install script
wget -q https://raw.githubusercontent.com/daniel-e/rustml/master/dl_datasets.sh
chmod +x dl_datasets.sh

# download the datasets and install them into ~/.rustml/
./dl_datasets.sh

Extension points exported contracts — how you extend this code

FunctionsInPlace (Interface)
Trait for common mathematical functions for scalars, vectors and matrices. [3 implementers]
src/ops_inplace.rs
Similar (Interface)
Trait to check if the values of two matrices with the same dimension differ only within a small range. [3 implementers]
src/matrix.rs
Functions (Interface)
Trait for common mathematical functions for scalars, vectors and matrices. [2 implementers]
src/ops.rs
Distance (Interface)
Computes the distance between two vectors. [2 implementers]
src/distance.rs
DesignMatrix (Interface)
Trait to create the design matrix of a matrix of features, i.e. a new column is inserted at the left of the matrix where [2 …
src/regression.rs
Image (Interface)
Trait for images. [2 implementers]
src/opencv/mod.rs
Scale (Interface)
Trait to estimate the mean and the variance of a set of samples. [1 implementers]
src/features.rs
Linspace (Interface)
Linearly spaced elements. [1 implementers]
src/vectors.rs

Core symbols most depended-on inside this repo

add
called by 127
src/octave.rs
len
called by 82
src/io.rs
cols
called by 58
src/matrix.rs
rows
called by 51
src/matrix.rs
iter
called by 50
src/io.rs
add_layer
called by 31
src/nn.rs
map
called by 27
src/matrix.rs
to_string
called by 21
src/octave.rs

Shape

Function 189
Method 170
Class 39
Interface 34
Enum 7

Languages

Rust100%

Modules by API surface

src/matrix.rs69 symbols
src/opencv/mod.rs55 symbols
src/ops_inplace.rs36 symbols
src/ops.rs34 symbols
src/nn.rs29 symbols
src/vectors.rs25 symbols
src/datasets.rs21 symbols
src/sliding.rs18 symbols
src/regression.rs14 symbols
src/octave.rs14 symbols
src/io.rs14 symbols
src/dbscan.rs12 symbols

For agents

$ claude mcp add rustml \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact