Refactor LogReg implementation for improved readability by adjusting formatting and organizing imports

This commit is contained in:
Palash Tyagi
2025-07-06 19:17:03 +01:00
parent 2ca496cfd1
commit 1c8fcc0bad

View File

@@ -1,5 +1,5 @@
use crate::matrix::{Matrix, SeriesOps};
use crate::compute::activations::sigmoid;
use crate::matrix::{Matrix, SeriesOps};
pub struct LogReg {
w: Matrix<f64>,
@@ -31,14 +31,14 @@ impl LogReg {
}
pub fn predict(&self, x: &Matrix<f64>) -> Matrix<f64> {
self.predict_proba(x).map(|p| if p >= 0.5 { 1.0 } else { 0.0 })
self.predict_proba(x)
.map(|p| if p >= 0.5 { 1.0 } else { 0.0 })
}
}
#[cfg(test)]
mod tests {
use super::LogReg;
use crate::matrix::Matrix;
use super::*;
#[test]
fn test_logreg_fit_predict() {