[−][src]Crate smartcore
SmartCore
Welcome to SmartCore, the most advanced machine learning library in Rust!
In SmartCore you will find implementation of these ML algorithms:
- Regression: Linear Regression (OLS), Decision Tree Regressor, Random Forest Regressor, K Nearest Neighbors
- Classification: Logistic Regressor, Decision Tree Classifier, Random Forest Classifier, Supervised Nearest Neighbors (KNN)
- Clustering: K-Means
- Matrix Decomposition: PCA, LU, QR, SVD, EVD
- Distance Metrics: Euclidian, Minkowski, Manhattan, Hamming, Mahalanobis
- Evaluation Metrics: Accuracy, AUC, Recall, Precision, F1, Mean Absolute Error, Mean Squared Error, R2
Most of algorithms implemented in SmartCore operate on n-dimentional arrays. While you can use Rust vectors with all functions defined in this library we do recommend to go with one of the popular linear algebra libraries available in Rust. At this moment we support these packages:
Getting Started
To start using SmartCore simply add the following to your Cargo.toml file:
[dependencies] smartcore = "0.1.0"
All ML algorithms in SmartCore are grouped into these generic 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
Each category is assigned to a separate module.
For example, KNN classifier is defined in smartcore::neighbors::knn_classifier. To train and run it using standard Rust vectors you will run this code:
// 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, Distances::euclidian(), Default::default()).unwrap(); // Predict classes let y_hat = knn.predict(&x).unwrap();
Modules
algorithm | Various algorithms and helper methods that are used elsewhere in SmartCore |
cluster | Algorithms for clustering of unlabeled data |
dataset | Various datasets Datasets |
decomposition | Matrix decomposition algorithms |
ensemble | Ensemble methods, including Random Forest classifier and regressor |
error | Custom warnings and errors |
linalg | Diverse collection of linear algebra abstractions and methods that power SmartCore algorithms |
linear | Supervised classification and regression models that assume linear relationship between dependent and explanatory variables. |
math | Helper methods and classes, including definitions of distance metrics |
metrics | Functions for assessing prediction error. |
model_selection | Model Selection methods |
neighbors | Supervised neighbors-based learning methods |
tree | Supervised tree-based learning methods |