Merge pull request #110 from morenol/nb/fix_docs
docs: fix documentation of naive bayes structs
This commit is contained in:
+1
-1
@@ -93,7 +93,7 @@ pub trait EVDDecomposableMatrix<T: RealNumber>: BaseMatrix<T> {
|
||||
sort(&mut d, &mut e, &mut V);
|
||||
}
|
||||
|
||||
Ok(EVD { V, d, e })
|
||||
Ok(EVD { d, e, V })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -966,7 +966,7 @@ mod tests {
|
||||
let error: f64 = y
|
||||
.into_iter()
|
||||
.zip(y_hat.into_iter())
|
||||
.map(|(&a, &b)| (a - b).abs())
|
||||
.map(|(a, b)| (a - b).abs())
|
||||
.sum();
|
||||
|
||||
assert!(error <= 1.0);
|
||||
|
||||
@@ -249,7 +249,8 @@ impl<T: RealNumber> BernoulliNBDistribution<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// BernoulliNB implements the categorical naive Bayes algorithm for categorically distributed data.
|
||||
/// BernoulliNB implements the naive Bayes algorithm for data that follows the Bernoulli
|
||||
/// distribution.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct BernoulliNB<T: RealNumber, M: Matrix<T>> {
|
||||
|
||||
@@ -232,8 +232,8 @@ impl<T: RealNumber> CategoricalNBDistribution<T> {
|
||||
class_labels,
|
||||
class_priors,
|
||||
coefficients,
|
||||
n_categories,
|
||||
n_features,
|
||||
n_categories,
|
||||
category_count,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use crate::naive_bayes::{BaseNaiveBayes, NBDistribution};
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Naive Bayes classifier for categorical features
|
||||
/// Naive Bayes classifier using Gaussian distribution
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct GaussianNBDistribution<T: RealNumber> {
|
||||
@@ -179,7 +179,8 @@ impl<T: RealNumber> GaussianNBDistribution<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// GaussianNB implements the categorical naive Bayes algorithm for categorically distributed data.
|
||||
/// GaussianNB implements the naive Bayes algorithm for data that follows the Gaussian
|
||||
/// distribution.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct GaussianNB<T: RealNumber, M: Matrix<T>> {
|
||||
|
||||
@@ -212,7 +212,7 @@ impl<T: RealNumber> MultinomialNBDistribution<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// MultinomialNB implements the categorical naive Bayes algorithm for categorically distributed data.
|
||||
/// MultinomialNB implements the naive Bayes algorithm for multinomially distributed data.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct MultinomialNB<T: RealNumber, M: Matrix<T>> {
|
||||
|
||||
@@ -134,10 +134,8 @@ where
|
||||
U: RealNumber,
|
||||
V: BaseVector<U>,
|
||||
{
|
||||
match self.get_num(category) {
|
||||
None => None,
|
||||
Some(&idx) => Some(make_one_hot::<U, V>(idx, self.num_categories)),
|
||||
}
|
||||
self.get_num(category)
|
||||
.map(|&idx| make_one_hot::<U, V>(idx, self.num_categories))
|
||||
}
|
||||
|
||||
/// Invert one-hot vector, back to the category
|
||||
|
||||
Reference in New Issue
Block a user