Skip to content

Commit d22be7d

Browse files
Volodymyr OrlovVolodymyr Orlov
authored andcommitted
fix: post-review changes
1 parent 32ae63a commit d22be7d

File tree

4 files changed

+1
-28
lines changed

4 files changed

+1
-28
lines changed

src/naive_bayes/bernoulli.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ pub struct BernoulliNBParameters<T: RealNumber> {
8888
}
8989

9090
impl<T: RealNumber> BernoulliNBParameters<T> {
91-
/// Create BernoulliNBParameters with specific paramaters.
92-
pub fn new(alpha: T, priors: Option<Vec<T>>, binarize: Option<T>) -> Self {
93-
Self {
94-
alpha,
95-
priors,
96-
binarize,
97-
}
98-
}
9991
/// Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing).
10092
pub fn with_alpha(mut self, alpha: T) -> Self {
10193
self.alpha = alpha;

src/naive_bayes/categorical.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,6 @@ pub struct CategoricalNBParameters<T: RealNumber> {
223223
}
224224

225225
impl<T: RealNumber> CategoricalNBParameters<T> {
226-
/// Create CategoricalNBParameters with specific paramaters.
227-
pub fn new(alpha: T) -> Result<Self, Failed> {
228-
if alpha > T::zero() {
229-
Ok(Self { alpha })
230-
} else {
231-
Err(Failed::fit(&format!(
232-
"alpha should be >= 0, alpha=[{}]",
233-
alpha
234-
)))
235-
}
236-
}
237226
/// Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing).
238227
pub fn with_alpha(mut self, alpha: T) -> Self {
239228
self.alpha = alpha;

src/naive_bayes/gaussian.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ pub struct GaussianNBParameters<T: RealNumber> {
8282
}
8383

8484
impl<T: RealNumber> GaussianNBParameters<T> {
85-
/// Create GaussianNBParameters with specific paramaters.
86-
pub fn new(priors: Option<Vec<T>>) -> Self {
87-
Self { priors }
88-
}
8985
/// Prior probabilities of the classes. If specified the priors are not adjusted according to the data
9086
pub fn with_priors(mut self, priors: Vec<T>) -> Self {
9187
self.priors = Some(priors);
@@ -266,7 +262,7 @@ mod tests {
266262
let y = vec![1., 1., 1., 2., 2., 2.];
267263

268264
let priors = vec![0.3, 0.7];
269-
let parameters = GaussianNBParameters::new(Some(priors.clone()));
265+
let parameters = GaussianNBParameters::default().with_priors(priors.clone());
270266
let gnb = GaussianNB::fit(&x, &y, parameters).unwrap();
271267

272268
assert_eq!(gnb.inner.distribution.class_priors, priors);

src/naive_bayes/multinomial.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ pub struct MultinomialNBParameters<T: RealNumber> {
8282
}
8383

8484
impl<T: RealNumber> MultinomialNBParameters<T> {
85-
/// Create MultinomialNBParameters with specific paramaters.
86-
pub fn new(alpha: T, priors: Option<Vec<T>>) -> Self {
87-
Self { alpha, priors }
88-
}
8985
/// Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing).
9086
pub fn with_alpha(mut self, alpha: T) -> Self {
9187
self.alpha = alpha;

0 commit comments

Comments
 (0)