Crates.io | dendritic-metrics |
lib.rs | dendritic-metrics |
version | 1.5.0 |
source | src |
created_at | 2024-10-28 12:59:49.156436 |
updated_at | 2024-11-01 19:42:51.427931 |
description | Metrics package for dendritic |
homepage | |
repository | |
max_upload_size | |
id | 1425598 |
size | 16,153 |
This crate contains metrics for measuring loss, accuracy of general ML models available for dendritic. Metrics contain loss and activiation functions.
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.
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());
}