1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! # ferrolearn-bayes
//!
//! Bayesian methods for the ferrolearn machine learning framework.
//!
//! Two families of tools live here:
//!
//! 1. **Naive Bayes classifiers** — five variants for classification.
//! 2. **Conjugate priors** — closed-form posterior updates for parameter
//! estimation. See [`conjugate`].
//!
//! This crate provides five Naive Bayes variants:
//!
//! - **[`GaussianNB`]** — Assumes Gaussian-distributed features. Suitable for
//! continuous data.
//! - **[`MultinomialNB`]** — For discrete count data (e.g., word counts).
//! Features must be non-negative.
//! - **[`BernoulliNB`]** — For binary/boolean features. Optional binarization
//! threshold.
//! - **[`CategoricalNB`]** — For categorical features where each column takes
//! on one of several discrete values. Laplace-smoothed.
//! - **[`ComplementNB`]** — A Multinomial NB variant that uses complement-class
//! statistics; better suited for imbalanced datasets.
//!
//! # Design
//!
//! Each classifier follows the compile-time safety pattern:
//!
//! - The unfitted struct (e.g., `GaussianNB<F>`) holds hyperparameters and
//! implements [`Fit`](ferrolearn_core::Fit).
//! - Calling `fit()` produces a fitted type (e.g., `FittedGaussianNB<F>`) that
//! implements [`Predict`](ferrolearn_core::Predict) and
//! [`HasClasses`](ferrolearn_core::introspection::HasClasses).
//! - The fitted types also expose a `predict_proba` method returning class
//! probabilities as `Array2<F>`.
//!
//! # Examples
//!
//! ```
//! use ferrolearn_bayes::GaussianNB;
//! use ferrolearn_core::{Fit, Predict};
//! use ndarray::{array, Array2};
//!
//! let x = Array2::from_shape_vec(
//! (6, 2),
//! vec![1.0, 2.0, 1.5, 2.5, 1.2, 1.8, 6.0, 7.0, 5.8, 6.5, 6.2, 7.2],
//! ).unwrap();
//! let y = array![0usize, 0, 0, 1, 1, 1];
//!
//! let model = GaussianNB::<f64>::new();
//! let fitted = model.fit(&x, &y).unwrap();
//! let preds = fitted.predict(&x).unwrap();
//! assert_eq!(preds.len(), 6);
//! ```
// Re-export all public types at the crate root.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;