#machine-learning #statistical #ai #optimization #linear-algebra

smartcore

The most advanced machine learning library in rust

2 unstable releases

0.2.0 Jan 3, 2021
0.1.0 Sep 26, 2020

#78 in Machine learning

34 downloads per month

Apache-2.0

725KB
16K SLoC

SmartCore

User guide | API | Examples


The Most Advanced Machine Learning Library In Rust.



lib.rs:

SmartCore

Welcome to SmartCore, the most advanced machine learning library in Rust!

SmartCore features various classification, regression and clustering algorithms including support vector machines, random forests, k-means and DBSCAN, as well as tools for model selection and model evaluation.

SmartCore is well integrated with a with wide variaty of libraries that provide support for large, multi-dimensional arrays and matrices. At this moment, all Smartcore's algorithms work with ordinary Rust vectors, as well as matrices and vectors defined in these packages:

Getting Started

To start using SmartCore simply add the following to your Cargo.toml file:

[dependencies]
smartcore = "0.2.0"

All machine learning algorithms in SmartCore are grouped into these broad categories:

  • Clustering, unsupervised clustering of unlabeled data.
  • Martix Decomposition, various methods for matrix decomposition.
  • Linear Models, regression and classification methods where output is assumed to have linear relation to explanatory variables
  • Ensemble Models, variety of regression and classification ensemble models
  • Tree-based Models, classification and regression trees
  • Nearest Neighbors, K Nearest Neighbors for classification and regression
  • Naive Bayes, statistical classification technique based on Bayes Theorem
  • SVM, support vector machines

For example, you can use this code to fit a K Nearest Neighbors classifier to a dataset that is defined as standard Rust vector:

// DenseMatrix defenition
use smartcore::linalg::naive::dense_matrix::*;
// KNNClassifier
use smartcore::neighbors::knn_classifier::*;
// Various distance metrics
use smartcore::math::distance::*;

// Turn Rust vectors with samples into a matrix
let x = DenseMatrix::from_2d_array(&[
   &[1., 2.],
   &[3., 4.],
   &[5., 6.],
   &[7., 8.],
   &[9., 10.]]);
// Our classes are defined as a Vector
let y = vec![2., 2., 2., 3., 3.];

// Train classifier
let knn = KNNClassifier::fit(&x, &y, Default::default()).unwrap();

// Predict classes
let y_hat = knn.predict(&x).unwrap();

Dependencies

~1.7–3MB
~65K SLoC