mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 04:00:01 +00:00
Refactor LogReg implementation for improved readability by adjusting formatting and organizing imports
This commit is contained in:
parent
2ca496cfd1
commit
1c8fcc0bad
@ -1,5 +1,5 @@
|
|||||||
use crate::matrix::{Matrix, SeriesOps};
|
|
||||||
use crate::compute::activations::sigmoid;
|
use crate::compute::activations::sigmoid;
|
||||||
|
use crate::matrix::{Matrix, SeriesOps};
|
||||||
|
|
||||||
pub struct LogReg {
|
pub struct LogReg {
|
||||||
w: Matrix<f64>,
|
w: Matrix<f64>,
|
||||||
@ -31,14 +31,14 @@ impl LogReg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn predict(&self, x: &Matrix<f64>) -> Matrix<f64> {
|
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 {
|
mod tests {
|
||||||
use super::LogReg;
|
use super::*;
|
||||||
use crate::matrix::Matrix;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_logreg_fit_predict() {
|
fn test_logreg_fit_predict() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user