1414from Orange .data import Table
1515from Orange .modelling import NNLearner
1616from Orange .widgets import gui
17+ from Orange .widgets .widget import Msg
1718from Orange .widgets .settings import Setting
1819from Orange .widgets .utils .owlearnerwidget import OWBaseLearner
1920
@@ -81,11 +82,11 @@ class OWNNLearner(OWBaseLearner):
8182 activation_index = Setting (3 )
8283 solver_index = Setting (2 )
8384 max_iterations = Setting (200 )
84- alpha_index = Setting (0 )
85+ alpha_index = Setting (1 )
8586 replicable = Setting (True )
86- settings_version = 1
87+ settings_version = 2
8788
88- alphas = list (chain ([x / 10000 for x in range (1 , 10 )],
89+ alphas = list (chain ([0 ], [ x / 10000 for x in range (1 , 10 )],
8990 [x / 1000 for x in range (1 , 10 )],
9091 [x / 100 for x in range (1 , 10 )],
9192 [x / 10 for x in range (1 , 10 )],
@@ -94,6 +95,11 @@ class OWNNLearner(OWBaseLearner):
9495 range (100 , 200 , 10 ),
9596 range (100 , 1001 , 50 )))
9697
98+ class Warning (OWBaseLearner .Warning ):
99+ no_layers = Msg ("ANN without hidden layers is equivalent to logistic "
100+ "regression with worse fitting.\n We recommend using "
101+ "logistic regression." )
102+
97103 def add_main_layout (self ):
98104 # this is part of init, pylint: disable=attribute-defined-outside-init
99105 form = QFormLayout ()
@@ -184,10 +190,10 @@ def get_learner_parameters(self):
184190 ("Replicable training" , self .replicable ))
185191
186192 def get_hidden_layers (self ):
193+ self .Warning .no_layers .clear ()
187194 layers = tuple (map (int , re .findall (r'\d+' , self .hidden_layers_input )))
188195 if not layers :
189- layers = (10 ,)
190- self .hidden_layers_input = "10,"
196+ self .Warning .no_layers ()
191197 return layers
192198
193199 def update_model (self ):
@@ -306,6 +312,8 @@ def migrate_settings(cls, settings, version):
306312 if alpha is not None :
307313 settings ["alpha_index" ] = \
308314 np .argmin (np .abs (np .array (cls .alphas ) - alpha ))
315+ elif version < 2 :
316+ settings ["alpha_index" ] = settings .get ("alpha_index" , 0 ) + 1
309317
310318
311319if __name__ == "__main__" : # pragma: no cover
0 commit comments