Crates.io | dendritic-bayes |
lib.rs | dendritic-bayes |
version | 1.5.0 |
source | src |
created_at | 2024-10-28 13:39:15.065718 |
updated_at | 2024-11-01 19:42:50.395203 |
description | Package for doing baysian statistics |
homepage | |
repository | |
max_upload_size | |
id | 1425628 |
size | 43,173 |
This crate allows for common bayesian methods for regression and classification tasks. The bayes crate currently supports guassian and standard naive bayes.
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.
To get started, add this to your Cargo.toml
:
[dependencies]
dendritic-bayes = "1.1.0"
This is an example of using both the naive and gaussian bayes models
use dendritic_ndarray::ndarray::NDArray;
use dendritic_ndarray::ops::*;
use dendritic_bayes::naive_bayes::*;
use dendritic_bayes::gaussian_bayes::*;
fn main() {
// Load datasets from saved ndarray
let x_path = "data/weather_multi_feature/inputs";
let y_path = "data/weather_multi_feature/outputs";
// Load saved ndarrays in memory
let features = NDArray::load(x_path).unwrap();
let target = NDArray::load(y_path).unwrap();
// Create instance of naive bayes model
let mut nb_clf = NaiveBayes::new(
&features,
&target
).unwrap();
// Create instance of guassian bayes model
let mut gb_clf = GaussianNB::new(
&features,
&target
).unwrap();
// Make prediction with first row of features
let row1 = features.axis(0, 0).unwrap();
let nb_pred = nb_clf.fit(row1.clone());
let gb_pred = gb_clf.fit(row1.clone()); // This will take in references eventually
}