Crate dendritic

Source
Expand description

§Dendritic Machine Learning Crate

Dendritic is a machine learning library for the Rust ecosystem. This crate contains your standard machine learning algorithms and utilities for numerical computation. There are multiple subcrates within this project that can be used to build machine learning models

§Disclaimer

The dendritic project is a toy machine learning library built for learning and research purposes. It is not advised by the maintainer to use this library as a production ready machine learning library. This is a project that is still very much a work in progress.

§Published Crates

Rust CrateDescription
dendritic_ndarrayN Dimensional array library for numerical computing
dendritic_datasetsVariety of datasets for regression and classification tasks
dendritic_autodiffAutodifferentiation crate for backward and forward operations
dendritic_metricsMetrics package for measuring loss and activiation functions for non linear boundaries
dendritic_preprocessingPreprocessing library for normalization and encoding of data
dendritic_bayesBayesian statistics package
dendritic_clusteringClustering package utilizing various distance metrics
dendritic_knnK Nearest Neighbors for regression and classification
dendritic_modelsPre-trained models for testing dendritic functionality
dendritic_regressionRegression package for linear modeling & multi class classification
dendritic_treesTree based models using decision trees and random forests

§Building The Dendritic Packages

Dendritic is made up of multiple indepedent packages that can be built separatley. To install a package, add the following to your Cargo.toml file.

[dependencies]
dendritic = { version = "<LATEST_VERSION>", features = ["bundled"] }

§Example IRIS Flowers Prediction

Down below is an example of using a multi class logstic regression model on the well known iris flowers dataset. For more examples, refer to the dendritic-models/src/main.rs file.

use dendritic_datasets::iris::*;
use dendritic_regression::logistic::*;
use dendritic_metrics::loss::*;
use dendritic_metrics::activations::*;
use dendritic_preprocessing::encoding::*;
fn main() {
    // load data
    let data_path = "../../datasets/data/iris.parquet";
    let (x_train, y_train) = load_iris(data_path).unwrap();
    // encode the target variables
    let mut encoder = OneHotEncoding::new(y_train.clone()).unwrap();
    let y_train_encoded = encoder.transform();
    // create logistic regression model
    let mut log_model = MultiClassLogistic::new(
        &x_train,
        &y_train_encoded,
        softmax,
        0.1
    ).unwrap();
    log_model.sgd(500, true, 5);
    let sample_index = 100;
    let x_test = x_train.batch(5).unwrap();
    let y_test = y_train.batch(5).unwrap();
    let y_pred = log_model.predict(x_test[sample_index].clone());
    println!("Actual: {:?}", y_test[sample_index]);
    println!("Prediction: {:?}", y_pred.values());
    let loss = mse(&y_test[sample_index], &y_pred).unwrap(); 
    println!("LOSS: {:?}", loss);  
}