@@ -346,10 +346,10 @@ def __init__(self, name: Optional[str],
346
346
The metric that should be maximized or minimized in order to choose
347
347
the best hyperparameter configuration.
348
348
349
- eval_final_performance [bool, default=True] :
349
+ eval_final_performance:
350
350
DEPRECATED! Use "use_test_set" instead!
351
351
352
- use_test_set [bool, default=True] :
352
+ use_test_set:
353
353
If the metrics should be calculated for the test set,
354
354
otherwise the test set is seperated but not used.
355
355
@@ -603,6 +603,11 @@ def input_data_sanity_checks(self, data, targets, **kwargs):
603
603
"PHOTONAI erases every data item that has a Nan Target" .format (str (nr_of_nans )))
604
604
self .X = self .X [~ nans_in_y ]
605
605
self .y = self .y [~ nans_in_y ]
606
+ new_kwargs = dict ()
607
+ for name , element_list in kwargs .items ():
608
+ new_kwargs [name ] = element_list [~ nans_in_y ]
609
+ self .kwargs = new_kwargs
610
+
606
611
except Exception as e :
607
612
# This is only for convenience so if it fails then never mind
608
613
logger .error ("Removing Nans in target vector failed: " + str (e ))
@@ -637,7 +642,9 @@ def disable_multiprocessing_recursively(pipe):
637
642
if hasattr (pipe , 'nr_of_processes' ):
638
643
pipe .nr_of_processes = 1
639
644
for child in pipe .elements :
640
- if hasattr (child , 'base_element' ):
645
+ if isinstance (child , Branch ):
646
+ Hyperpipe .disable_multiprocessing_recursively (child )
647
+ elif hasattr (child , 'base_element' ):
641
648
Hyperpipe .disable_multiprocessing_recursively (child .base_element )
642
649
elif isinstance (pipe , PhotonPipeline ):
643
650
for name , child in pipe .named_steps .items ():
@@ -866,7 +873,8 @@ def _finalize_optimization(self):
866
873
self .optimum_pipe .fit (self .data .X , self .data .y , ** self .data .kwargs )
867
874
868
875
# Before saving the optimum pipe, add preprocessing without multiprocessing
869
- self .optimum_pipe .add_preprocessing (self .disable_multiprocessing_recursively (self .preprocessing ))
876
+ self .disable_multiprocessing_recursively (self .preprocessing )
877
+ self .optimum_pipe .add_preprocessing (self .preprocessing )
870
878
871
879
# Now truly set to no caching (including single_subject_caching)
872
880
self .recursive_cache_folder_propagation (self .optimum_pipe , None , None )
@@ -939,11 +947,8 @@ def _prepare_pipeline(self):
939
947
# ===================================================================
940
948
941
949
@staticmethod
942
- def fit_outer_folds (outer_fold_computer , X , y , kwargs , cache_folder ):
943
- try :
944
- outer_fold_computer .fit (X , y , ** kwargs )
945
- finally :
946
- CacheManager .clear_cache_files (cache_folder )
950
+ def fit_outer_folds (outer_fold_computer , X , y , kwargs ):
951
+ outer_fold_computer .fit (X , y , ** kwargs )
947
952
return
948
953
949
954
def fit (self , data : np .ndarray , targets : np .ndarray , ** kwargs ):
@@ -1038,8 +1043,7 @@ def fit(self, data: np.ndarray, targets: np.ndarray, **kwargs):
1038
1043
result = dask .delayed (Hyperpipe .fit_outer_folds )(outer_fold_computer ,
1039
1044
self .data .X ,
1040
1045
self .data .y ,
1041
- self .data .kwargs ,
1042
- self .cache_folder )
1046
+ self .data .kwargs )
1043
1047
delayed_jobs .append (result )
1044
1048
else :
1045
1049
try :
@@ -1058,7 +1062,8 @@ def fit(self, data: np.ndarray, targets: np.ndarray, **kwargs):
1058
1062
# evaluate hyperparameter optimization results for best config
1059
1063
self ._finalize_optimization ()
1060
1064
1061
- # clear complete cache ?
1065
+ # clear complete cache ? use self.cache_folder to delete all subfolders within the parent cache folder
1066
+ # directory
1062
1067
CacheManager .clear_cache_files (self .cache_folder , force_all = True )
1063
1068
1064
1069
###############################################################################################
@@ -1247,15 +1252,6 @@ def get_permutation_feature_importances(self, **kwargs):
1247
1252
Returns mean of "importances_mean" and of "importances_std" of all outer folds.
1248
1253
1249
1254
Parameters:
1250
- X_val:
1251
- The array-like data with shape=[M, D],
1252
- where M is the number of samples and D is the number
1253
- of features. D must correspond to the number
1254
- of trained dimensions of the fit method.
1255
-
1256
- y_val:
1257
- The array-like true targets.
1258
-
1259
1255
**kwargs:
1260
1256
Keyword arguments, passed to sklearn.permutation_importance.
1261
1257
0 commit comments