#machine-learning #machine #learning #matrices #linear-algebra


Matrix and linear algebra library aimed at being easy to use

10 stable releases

1.7.0 Sep 7, 2021
1.6.1 May 9, 2021
1.5.0 Jan 27, 2021
1.4.0 Sep 20, 2020
1.0.0 Feb 9, 2020

#19 in Machine learning

Download history 17/week @ 2021-07-03 30/week @ 2021-07-10 29/week @ 2021-07-17 25/week @ 2021-07-24 50/week @ 2021-07-31 5/week @ 2021-08-07 29/week @ 2021-08-14 30/week @ 2021-08-21 11/week @ 2021-08-28 21/week @ 2021-09-04 28/week @ 2021-09-11 34/week @ 2021-09-18 99/week @ 2021-09-25 101/week @ 2021-10-02 26/week @ 2021-10-09 7/week @ 2021-10-16

96 downloads per month

MPL-2.0 license

4.5K SLoC

Easy ML

A completely deterministic matrix and linear algebra library over generic number types aimed at being easy to use.


Add easy-ml = "1.7" to your [dependencies]1.


This is a pure Rust library which makes heavy use of passing closures, iterators, generic types, and other rust idioms that machine learning libraries which wrap around another language backend could never provide easily. This library tries to provide adequate documentation to explain what the functions compute, what the computations mean, and examples of tasks you might want to do with this library:

  • Linear Regression
  • k-means Clustering
  • Logistic Regression
  • Naïve Bayes
  • Feedforward neural networks
  • Backprop with Automatic Differentiation
  • using a custom numeric type such as num_bigint::BigInt
  • Handwritten digit recognition in the browser

This library is not designed for deep learning. I have not tried to optimise much of anything. The implementations of everything are more or less textbook mathematical definitions. You might find that you need to use a faster library once you've explored your problem, or that you need something that's not implemented here and have to switch. I hope that being able to at least start here may be of use.

State of library

This library is currently usable for simple linear algebra tasks like linear regression and for storing 2 dimensional data. This library also has support for forward and reverse automatic differentiation and can train simple feedforward neural networks. Currently there is no support for 3d or higher dimensional data, though matrices can be nested into each other. This library supports compilation to Web Assembly.

Level of abstraction

Where as other machine learning libraries often create objects/structs to represent algorithms like linear regression or k-means, Easy ML instead only represents the data in structs and the consuming code determines all of the control flow. While this may take more effort to write for consuming code initially, it means making changes to the algorithms are much easier.

1 - If you need to freeze your rust compiler version you should specify a minor version with a tilde requirement such as easy-ml = "~1.7". Easy ML will not introduce breaking API changes between minor versions, but does follow the latest stable version of rust, and thus may introduce dependencies on newer language features (eg const generics) in minor version updates.