Browse Source

add of tracking of number index of sub-model

Jérôme BUISINE 1 year ago
parent
commit
7b1d0c7b13

+ 3 - 3
find_best_attributes_surrogate_openML_multi_specific.py

@@ -184,7 +184,7 @@ def main():
 
         return test_roc_auc
 
-    def sub_evaluate(solution, targeted_indices):
+    def sub_evaluate(solution, index_number, targeted_indices):
 
         start = datetime.datetime.now()
 
@@ -195,7 +195,7 @@ def main():
             if value == 1: 
                 indices.append(targeted_indices[index]) 
 
-        print(f'Training sub-model SVM with {len(indices)} from {len(solution._data)} available features')
+        print(f'Training sub-model SVM n°{index_number} with {len(indices)} from {len(solution._data)} available features')
 
         # keep only selected filters from solution
         x_train_filters = X_train[:, indices]
@@ -212,7 +212,7 @@ def main():
 
         diff = end - start
 
-        print("Real sub-evaluation took: {}, score found: {}".format(divmod(diff.days * 86400 + diff.seconds, 60), test_roc_auc))
+        print(f"Real sub-evaluation n°{index_number} took: {divmod(diff.days * 86400 + diff.seconds, 60)}, score found: {test_roc_auc}")
 
         return test_roc_auc
 

+ 2 - 3
optimization/ILSMultiSpecificSurrogate.py

@@ -133,7 +133,7 @@ class ILSMultiSpecificSurrogate(Algorithm):
         for i in range(len(self._k_indices)):
 
             # need to pass as default argument indices
-            current_evaluator = lambda s, indices=self._k_indices[i]: self._sub_evaluator(s, indices)
+            current_evaluator = lambda s, number=i, indices=self._k_indices[i]: self._sub_evaluator(s, number, indices)
             self._sub_evaluators.append(current_evaluator)
 
 
@@ -191,7 +191,7 @@ class ILSMultiSpecificSurrogate(Algorithm):
         df = pd.read_csv(self._solutions_files[index], sep=';')
         # learning set and test set
         current_learn = df.sample(training_samples)
-        current_test = df.drop(learn.index)
+        current_test = df.drop(current_learn.index)
 
         # TODO : (check) not necessary now to select specific features indices into set
         # current_learn = learn.copy()
@@ -375,7 +375,6 @@ class ILSMultiSpecificSurrogate(Algorithm):
         self.init_population()
 
         # count number of surrogate obtained and restart using real evaluations done for each surrogate (sub-model)
-
         if (self._start_train_surrogates * self._k_division) > self.getGlobalEvaluation():
 
             # for each sub problem (surrogate)