feat: NB documentation

This commit is contained in:
Volodymyr Orlov
2020-12-17 19:00:11 -08:00
parent 2c892aa603
commit 5a185479a7
6 changed files with 167 additions and 10 deletions
+32
View File
@@ -1,3 +1,35 @@
//! # Categorical Naive Bayes
//!
//! Categorical Naive Bayes is a variant of [Naive Bayes](../index.html) for the categorically distributed data.
//! It assumes that each feature has its own categorical distribution.
//!
//! Example:
//!
//! ```
//! use smartcore::linalg::naive::dense_matrix::*;
//! use smartcore::naive_bayes::categorical::CategoricalNB;
//!
//! let x = DenseMatrix::from_2d_array(&[
//! &[3., 4., 0., 1.],
//! &[3., 0., 0., 1.],
//! &[4., 4., 1., 2.],
//! &[4., 2., 4., 3.],
//! &[4., 2., 4., 2.],
//! &[4., 1., 1., 0.],
//! &[1., 1., 1., 1.],
//! &[0., 4., 1., 0.],
//! &[0., 3., 2., 1.],
//! &[0., 3., 1., 1.],
//! &[3., 4., 0., 1.],
//! &[3., 4., 2., 4.],
//! &[0., 3., 1., 2.],
//! &[0., 4., 1., 2.],
//! ]);
//! let y = vec![0., 0., 1., 1., 1., 0., 1., 0., 1., 1., 1., 1., 1., 0.];
//!
//! let nb = CategoricalNB::fit(&x, &y, Default::default()).unwrap();
//! let y_hat = nb.predict(&x).unwrap();
//! ```
use crate::error::Failed;
use crate::linalg::BaseVector;
use crate::linalg::Matrix;