fix: post-review changes

This commit is contained in:
Volodymyr Orlov
2020-12-24 13:47:09 -08:00
parent 32ae63a577
commit d22be7d6ae
4 changed files with 1 additions and 28 deletions
-8
View File
@@ -88,14 +88,6 @@ pub struct BernoulliNBParameters<T: RealNumber> {
}
impl<T: RealNumber> BernoulliNBParameters<T> {
/// Create BernoulliNBParameters with specific paramaters.
pub fn new(alpha: T, priors: Option<Vec<T>>, binarize: Option<T>) -> Self {
Self {
alpha,
priors,
binarize,
}
}
/// Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing).
pub fn with_alpha(mut self, alpha: T) -> Self {
self.alpha = alpha;
-11
View File
@@ -223,17 +223,6 @@ pub struct CategoricalNBParameters<T: RealNumber> {
}
impl<T: RealNumber> CategoricalNBParameters<T> {
/// Create CategoricalNBParameters with specific paramaters.
pub fn new(alpha: T) -> Result<Self, Failed> {
if alpha > T::zero() {
Ok(Self { alpha })
} else {
Err(Failed::fit(&format!(
"alpha should be >= 0, alpha=[{}]",
alpha
)))
}
}
/// Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing).
pub fn with_alpha(mut self, alpha: T) -> Self {
self.alpha = alpha;
+1 -5
View File
@@ -82,10 +82,6 @@ pub struct GaussianNBParameters<T: RealNumber> {
}
impl<T: RealNumber> GaussianNBParameters<T> {
/// Create GaussianNBParameters with specific paramaters.
pub fn new(priors: Option<Vec<T>>) -> Self {
Self { priors }
}
/// Prior probabilities of the classes. If specified the priors are not adjusted according to the data
pub fn with_priors(mut self, priors: Vec<T>) -> Self {
self.priors = Some(priors);
@@ -266,7 +262,7 @@ mod tests {
let y = vec![1., 1., 1., 2., 2., 2.];
let priors = vec![0.3, 0.7];
let parameters = GaussianNBParameters::new(Some(priors.clone()));
let parameters = GaussianNBParameters::default().with_priors(priors.clone());
let gnb = GaussianNB::fit(&x, &y, parameters).unwrap();
assert_eq!(gnb.inner.distribution.class_priors, priors);
-4
View File
@@ -82,10 +82,6 @@ pub struct MultinomialNBParameters<T: RealNumber> {
}
impl<T: RealNumber> MultinomialNBParameters<T> {
/// Create MultinomialNBParameters with specific paramaters.
pub fn new(alpha: T, priors: Option<Vec<T>>) -> Self {
Self { alpha, priors }
}
/// Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing).
pub fn with_alpha(mut self, alpha: T) -> Self {
self.alpha = alpha;