fix: fixes suggested by Clippy
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
//!
|
||||
//! <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
||||
//! <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::Debug;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
@@ -232,12 +233,12 @@ impl<T: RealNumber, M: Matrix<T>> LogisticRegression<T, M> {
|
||||
yi[i] = classes.iter().position(|c| yc == *c).unwrap();
|
||||
}
|
||||
|
||||
if k < 2 {
|
||||
Err(Failed::fit(&format!(
|
||||
match k.cmp(&2) {
|
||||
Ordering::Less => Err(Failed::fit(&format!(
|
||||
"incorrect number of classes: {}. Should be >= 2.",
|
||||
k
|
||||
)))
|
||||
} else if k == 2 {
|
||||
))),
|
||||
Ordering::Equal => {
|
||||
let x0 = M::zeros(1, num_attributes + 1);
|
||||
|
||||
let objective = BinaryObjectiveFunction {
|
||||
@@ -256,7 +257,8 @@ impl<T: RealNumber, M: Matrix<T>> LogisticRegression<T, M> {
|
||||
num_attributes: num_attributes,
|
||||
num_classes: k,
|
||||
})
|
||||
} else {
|
||||
}
|
||||
Ordering::Greater => {
|
||||
let x0 = M::zeros(1, (num_attributes + 1) * k);
|
||||
|
||||
let objective = MultiClassObjectiveFunction {
|
||||
@@ -279,6 +281,7 @@ impl<T: RealNumber, M: Matrix<T>> LogisticRegression<T, M> {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Predict class labels for samples in `x`.
|
||||
/// * `x` - _KxM_ data where _K_ is number of observations and _M_ is number of features.
|
||||
@@ -286,7 +289,6 @@ impl<T: RealNumber, M: Matrix<T>> LogisticRegression<T, M> {
|
||||
let n = x.shape().0;
|
||||
let mut result = M::zeros(1, n);
|
||||
if self.num_classes == 2 {
|
||||
let (nrows, _) = x.shape();
|
||||
let y_hat: Vec<T> = x.matmul(&self.coefficients.transpose()).get_col_as_vec(0);
|
||||
let intercept = self.intercept.get(0, 0);
|
||||
for i in 0..n {
|
||||
|
||||
Reference in New Issue
Block a user