File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -579,6 +579,48 @@ pub struct LogisticModel {
579
579
adj_r2 : f64 ,
580
580
}
581
581
582
+ impl LogisticModel {
583
+ #[ inline]
584
+ #[ cfg_attr( coverage_nightly, coverage( off) ) ]
585
+ pub fn slopes ( & self ) -> & [ f64 ] {
586
+ & self . slopes
587
+ }
588
+
589
+ #[ inline]
590
+ #[ cfg_attr( coverage_nightly, coverage( off) ) ]
591
+ pub fn intercept ( & self ) -> f64 {
592
+ self . intercept
593
+ }
594
+
595
+ #[ inline]
596
+ #[ cfg_attr( coverage_nightly, coverage( off) ) ]
597
+ pub fn predicted ( & self ) -> & [ f64 ] {
598
+ & self . predicted
599
+ }
600
+
601
+ #[ inline]
602
+ #[ cfg_attr( coverage_nightly, coverage( off) ) ]
603
+ pub fn r2 ( & self ) -> f64 {
604
+ self . r2
605
+ }
606
+
607
+ #[ inline]
608
+ #[ cfg_attr( coverage_nightly, coverage( off) ) ]
609
+ pub fn adj_r2 ( & self ) -> f64 {
610
+ self . adj_r2
611
+ }
612
+
613
+ pub fn predict ( & self , x : & [ f64 ] ) -> f64 {
614
+ self . intercept
615
+ + self
616
+ . slopes
617
+ . iter ( )
618
+ . zip ( x. iter ( ) )
619
+ . map ( |( a, b) | a * b)
620
+ . sum :: < f64 > ( )
621
+ }
622
+ }
623
+
582
624
#[ inline( always) ]
583
625
fn logit ( x : f64 ) -> f64 {
584
626
( x / ( 1.0 - x) ) . ln ( )
You can’t perform that action at this time.
0 commit comments