3
3
#![ warn( rustdoc:: missing_doc_code_examples) ]
4
4
#![ warn( clippy:: missing_docs_in_private_items) ]
5
5
#![ doc = include_str ! ( "../README.md" ) ]
6
- #![ cfg_attr( docsrs, feature( doc_cfg) ) ]
7
6
8
7
pub mod settings;
9
8
pub use settings:: Settings ;
@@ -44,9 +43,6 @@ use std::{
44
43
#[ cfg( any( feature = "nd" ) ) ]
45
44
use ndarray:: { Array1 , Array2 } ;
46
45
47
- #[ cfg( any( feature = "gui" ) ) ]
48
- use eframe:: { egui, epi} ;
49
-
50
46
#[ cfg( any( feature = "csv" ) ) ]
51
47
use {
52
48
polars:: prelude:: { DataFrame , Float32Type } ,
@@ -174,8 +170,6 @@ pub struct SupervisedModel {
174
170
Option < PCA < f32 , DenseMatrix < f32 > > > ,
175
171
Option < SVD < f32 , DenseMatrix < f32 > > > ,
176
172
) ,
177
- #[ cfg( any( feature = "gui" ) ) ]
178
- current_x : Vec < f32 > ,
179
173
}
180
174
181
175
impl SupervisedModel {
@@ -567,27 +561,6 @@ impl SupervisedModel {
567
561
}
568
562
}
569
563
570
- #[ cfg_attr( docsrs, doc( cfg( feature = "gui" ) ) ) ]
571
- #[ cfg( any( feature = "gui" ) ) ]
572
- impl SupervisedModel {
573
- /// Runs an interactive GUI to demonstrate the final model
574
- /// ```no_run
575
- /// # use automl::{SupervisedModel, Settings};
576
- /// let mut model = SupervisedModel::new(
577
- /// smartcore::dataset::diabetes::load_dataset(),
578
- /// Settings::default_regression()
579
- /// # .only(automl::settings::Algorithm::Linear)
580
- /// );
581
- /// model.train();
582
- /// model.run_gui();
583
- /// ```
584
- /// 
585
- pub fn run_gui ( self ) {
586
- let native_options = eframe:: NativeOptions :: default ( ) ;
587
- eframe:: run_native ( Box :: new ( self ) , native_options) ;
588
- }
589
- }
590
-
591
564
/// Private functions go here
592
565
impl SupervisedModel {
593
566
fn build ( x : DenseMatrix < f32 > , y : Vec < f32 > , settings : Settings ) -> Self {
@@ -599,8 +572,6 @@ impl SupervisedModel {
599
572
y_val : vec ! [ ] ,
600
573
number_of_classes : Self :: count_classes ( & y) ,
601
574
comparison : vec ! [ ] ,
602
- #[ cfg( any( feature = "gui" ) ) ]
603
- current_x : vec ! [ 0.0 ; x. shape( ) . 1 ] ,
604
575
preprocessing : ( None , None ) ,
605
576
metamodel : Default :: default ( ) ,
606
577
}
@@ -881,54 +852,6 @@ impl Display for SupervisedModel {
881
852
}
882
853
}
883
854
884
- #[ cfg_attr( docsrs, doc( cfg( feature = "gui" ) ) ) ]
885
- #[ cfg( any( feature = "gui" ) ) ]
886
- impl epi:: App for SupervisedModel {
887
- fn update ( & mut self , ctx : & egui:: CtxRef , _frame : & mut epi:: Frame < ' _ > ) {
888
- egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
889
- // Add a heading that displays the type of model this is
890
- ui. heading ( format ! ( "{}" , self . comparison[ 0 ] . name) ) ;
891
-
892
- // Add a label that shows the prediction
893
- ui. label ( format ! (
894
- "Prediction: y = {}" ,
895
- self . predict( vec![ self . current_x. to_vec( ) ; 1 ] ) [ 0 ]
896
- ) ) ;
897
-
898
- // Separating the model name and prediction from the input values
899
- ui. separator ( ) ;
900
-
901
- // Step through input values to make sliders
902
- for i in 0 ..self . current_x . len ( ) {
903
- // Figure out the maximum in the training dataa
904
- let maxx = self
905
- . x_train
906
- . get_col_as_vec ( i)
907
- . iter ( )
908
- . cloned ( )
909
- . fold ( 0. / 0. , f32:: max) ;
910
-
911
- // Figure out the minimum in the training data
912
- let minn = self
913
- . x_train
914
- . get_col_as_vec ( i)
915
- . iter ( )
916
- . cloned ( )
917
- . fold ( 0. / 0. , f32:: min) ;
918
-
919
- // Add the slider
920
- ui. add (
921
- egui:: Slider :: new ( & mut self . current_x [ i] , minn..=maxx) . text ( format ! ( "x_{}" , i) ) ,
922
- ) ;
923
- }
924
- } ) ;
925
- }
926
-
927
- fn name ( & self ) -> & str {
928
- "Model Demo"
929
- }
930
- }
931
-
932
855
/// This contains the results of a single model
933
856
#[ derive( serde:: Serialize , serde:: Deserialize ) ]
934
857
struct Model {
0 commit comments