#dendritic #metrics #activation #loss #linear #non #ndarray

dendritic-metrics

Metrics package for dendritic

5 stable releases

1.5.0 Nov 1, 2024
1.4.0 Nov 1, 2024
1.1.0 Oct 28, 2024

#298 in Math

Download history 405/week @ 2024-10-26 175/week @ 2024-11-02 10/week @ 2024-11-09

590 downloads per month
Used in 7 crates

MIT license

12KB
160 lines

Dendritic Metrics Crate

This crate contains metrics for measuring loss, accuracy of general ML models available for dendritic. Metrics contain loss and activiation functions.

Features

  • Activations: Activation functions for non linear data.
  • Loss: Loss functions for measuring accuracy of classifiers/regressors

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.

Example Usage

This is an example of some of the loss and activation functions dendritic has to offer

use dendritic_ndarray::ndarray::NDArray;
use dendritic_ndarray::ops::*;
use dendritic_metrics::activations::*; 
use dendritic_metrics::loss::*; 

fn main() {

    // Mocked Prediction values
    let y_pred: NDArray<f64> = NDArray::array(
        vec![10, 1],
        vec![
            0.0, 0.0, 1.0, 0.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0
        ]
     ).unwrap();

     // Mocked true values
     let y_true: NDArray<f64> = NDArray::array(
        vec![10, 1],
        vec![
            0.19, 0.33, 0.47, 0.7, 0.74,
            0.81, 0.86, 0.94, 0.97, 0.99
        ]
     ).unwrap();

     // Calculate binary cross entropy for predicted and true values
     let result = binary_cross_entropy(&y_true, &y_pred).unwrap();
     println!("{:?}", result); 

     // Input dataset to perform softmax activation
     let input: NDArray<f64> = NDArray::array(
        vec![3, 1],
        vec![1.0, 1.0, 1.0]
     ).unwrap();

     let sm_result = softmax_prime(input);
     println!("{:?}", sm_result.values()); 
}

Dependencies

~1.4–2.4MB
~49K SLoC