@@ -33,14 +33,14 @@ def _get_param_types_maxint(params):
3333 types - list of types for each parameter
3434 maxints - list of maximum integer for each particular gene in chromosome
3535 """
36- name_values = params .items ()
36+ name_values = list ( params .items () )
3737 types = []
3838 for _ , possible_values in name_values :
3939 if isinstance (possible_values [0 ], float ):
4040 types .append (param_types .Numerical )
4141 else :
4242 types .append (param_types .Categorical )
43- maxints = [len (possible_values )- 1 for _ , possible_values in name_values ]
43+ maxints = [len (possible_values ) - 1 for _ , possible_values in name_values ]
4444 return name_values , types , maxints
4545
4646
@@ -96,10 +96,10 @@ def _evalFunction(individual, searchobj, name_values, X, y, scorer, cv, iid, fit
9696 searchobj .num_evaluations += 1
9797 searchobj .score_cache [paramkey ] = _score
9898 if searchobj .verbose and (searchobj .num_evaluations + searchobj .num_cache_hits ) % searchobj .population_size == 0 :
99- print "Scoring evaluations: %d, Cache hits: %d, Total: %d" % (
100- searchobj .num_evaluations , searchobj .num_cache_hits , searchobj .num_evaluations + searchobj .num_cache_hits )
99+ print ( "Scoring evaluations: %d, Cache hits: %d, Total: %d" % (
100+ searchobj .num_evaluations , searchobj .num_cache_hits , searchobj .num_evaluations + searchobj .num_cache_hits ))
101101 if iid :
102- score += _score * len (test )
102+ score += _score * len (test )
103103 n_test += len (test )
104104 else :
105105 score += _score
@@ -341,7 +341,7 @@ def _fit(self, X, y, parameter_dict):
341341 stats .register ("max" , np .max )
342342
343343 if self .verbose :
344- print ('--- Evolve in {0} possible combinations ---' .format (np .prod (np .array (maxints )+ 1 )))
344+ print ('--- Evolve in {0} possible combinations ---' .format (np .prod (np .array (maxints ) + 1 )))
345345
346346 pop , logbook = algorithms .eaSimple (pop , toolbox , cxpb = 0.5 , mutpb = 0.2 ,
347347 ngen = self .generations_number , stats = stats ,
@@ -352,10 +352,9 @@ def _fit(self, X, y, parameter_dict):
352352
353353 if self .verbose :
354354 print ("Best individual is: %s\n with fitness: %s" % (
355- current_best_params_ , current_best_score_ )
356- )
357- print "Scoring evaluations: %d, Cache hits: %d, Total: %d" % (
358- self .num_evaluations , self .num_cache_hits , self .num_evaluations + self .num_cache_hits )
355+ current_best_params_ , current_best_score_ ))
356+ print ("Scoring evaluations: %d, Cache hits: %d, Total: %d" % (
357+ self .num_evaluations , self .num_cache_hits , self .num_evaluations + self .num_cache_hits ))
359358
360359 if current_best_score_ > self .best_score_ :
361360 self .best_score_ = current_best_score_
0 commit comments