@@ -129,7 +129,7 @@ def extract_features(timeseries_container, default_fc_parameters=None,
129
129
"""
130
130
import logging
131
131
logging .basicConfig ()
132
-
132
+
133
133
# Always use the standardized way of storing the data.
134
134
# See the function normalize_input_to_internal_representation for more information.
135
135
kind_to_df_map , column_id , column_value = \
@@ -155,9 +155,11 @@ def extract_features(timeseries_container, default_fc_parameters=None,
155
155
156
156
# Calculate the result
157
157
if parallelization == 'per_kind' :
158
- calculation_function = _extract_features_parallel_per_kind
158
+ calculation_function = _extract_features_per_kind
159
159
elif parallelization == 'per_sample' :
160
160
calculation_function = _extract_features_parallel_per_sample
161
+ elif parallelization == 'serial' :
162
+ calculation_function = partial (_extract_features_per_kind , serial = True )
161
163
else :
162
164
raise ValueError ("Argument parallelization must be one of: 'per_kind', 'per_sample'" )
163
165
@@ -181,14 +183,15 @@ def extract_features(timeseries_container, default_fc_parameters=None,
181
183
return result
182
184
183
185
184
- def _extract_features_parallel_per_kind (kind_to_df_map ,
185
- column_id , column_value ,
186
- default_fc_parameters ,
187
- kind_to_fc_parameters = None ,
188
- chunksize = defaults .CHUNKSIZE ,
189
- n_processes = defaults .N_PROCESSES , show_warnings = defaults .SHOW_WARNINGS ,
190
- disable_progressbar = defaults .DISABLE_PROGRESSBAR ,
191
- impute_function = defaults .IMPUTE_FUNCTION ):
186
+ def _extract_features_per_kind (kind_to_df_map ,
187
+ column_id , column_value ,
188
+ default_fc_parameters ,
189
+ kind_to_fc_parameters = None ,
190
+ chunksize = defaults .CHUNKSIZE ,
191
+ n_processes = defaults .N_PROCESSES , show_warnings = defaults .SHOW_WARNINGS ,
192
+ disable_progressbar = defaults .DISABLE_PROGRESSBAR ,
193
+ impute_function = defaults .IMPUTE_FUNCTION ,
194
+ serial = False ):
192
195
"""
193
196
Parallelize the feature extraction per kind.
194
197
@@ -226,6 +229,9 @@ def _extract_features_parallel_per_kind(kind_to_df_map,
226
229
:param impute_function: None, if no imputing should happen or the function to call for imputing.
227
230
:type impute_function: None or function
228
231
232
+ :param serial: Run in serial instead of in parallel mode for performance testing
233
+ :type serial: bool
234
+
229
235
:return: The (maybe imputed) DataFrame containing extracted features.
230
236
:rtype: pandas.DataFrame
231
237
"""
@@ -241,8 +247,14 @@ def _extract_features_parallel_per_kind(kind_to_df_map,
241
247
chunksize = _calculate_best_chunksize (kind_to_df_map , n_processes )
242
248
243
249
total_number_of_expected_results = len (kind_to_df_map )
244
- extracted_features = tqdm (pool .imap_unordered (partial_extract_features_for_one_time_series , kind_to_df_map .items (),
245
- chunksize = chunksize ), total = total_number_of_expected_results ,
250
+
251
+ if serial :
252
+ map_function = map
253
+ else :
254
+ map_function = partial (pool .imap_unordered , chunksize = chunksize )
255
+
256
+ extracted_features = tqdm (map_function (partial_extract_features_for_one_time_series , kind_to_df_map .items ()),
257
+ total = total_number_of_expected_results ,
246
258
desc = "Feature Extraction" , disable = disable_progressbar )
247
259
pool .close ()
248
260
0 commit comments