@@ -222,6 +222,7 @@ def export_model(path, out):
222
222
def run_pipeline (run , hyperparameters , dataset ,
223
223
data_dir ,
224
224
out_dir ,
225
+ model_settings = dict (),
225
226
n_splits = 5 ,
226
227
features = 'timebased' ,
227
228
):
@@ -252,6 +253,14 @@ def run_pipeline(run, hyperparameters, dataset,
252
253
'running' , 'rope_jumping' ,
253
254
],
254
255
),
256
+ 'har_exercise_1' : dict (
257
+ groups = ['file' ],
258
+ data_columns = ['x' , 'y' , 'z' ],
259
+ classes = [
260
+ #'mixed',
261
+ 'squat' , 'jumpingjack' , 'lunge' , 'other' ,
262
+ ],
263
+ ),
255
264
}
256
265
257
266
if not os .path .exists (out_dir ):
@@ -272,8 +281,16 @@ def run_pipeline(run, hyperparameters, dataset,
272
281
data_load_duration = time .time () - data_load_start
273
282
log .info ('data-loaded' , dataset = dataset , samples = len (data ), duration = data_load_duration )
274
283
284
+
285
+
275
286
feature_extraction_start = time .time ()
276
- features = extract_features (data , columns = data_columns , groupby = groups , features = features )
287
+ features = extract_features (data ,
288
+ columns = data_columns ,
289
+ groupby = groups ,
290
+ features = features ,
291
+ window_length = model_settings ['window_length' ],
292
+ window_hop = model_settings ['window_hop' ],
293
+ )
277
294
labeled = numpy .count_nonzero (features ['activity' ].notna ())
278
295
279
296
feature_extraction_duration = time .time () - feature_extraction_start
@@ -293,9 +310,10 @@ def run_pipeline(run, hyperparameters, dataset,
293
310
print ('Class distribution\n ' , features ['activity' ].value_counts (dropna = False ))
294
311
295
312
# Run train-evaluate
313
+ evaluate_groupby = groups [0 ]
296
314
results , estimator = evaluate (features ,
297
315
hyperparameters = hyperparameters ,
298
- groupby = 'subject' ,
316
+ groupby = evaluate_groupby ,
299
317
n_splits = n_splits ,
300
318
)
301
319
@@ -362,6 +380,10 @@ def parse():
362
380
363
381
parser .add_argument ('--features' , type = str , default = 'timebased' ,
364
382
help = 'Which feature-set to use' )
383
+ parser .add_argument ('--window-length' , type = int , default = 128 ,
384
+ help = 'Length of each window to classify (in samples)' )
385
+ parser .add_argument ('--window-hop' , type = int , default = 64 ,
386
+ help = 'How far to hop for next window to classify (in samples)' )
365
387
366
388
args = parser .parse_args ()
367
389
@@ -391,6 +413,10 @@ def main():
391
413
data_dir = args .data_dir ,
392
414
run = run_id ,
393
415
hyperparameters = hyperparameters ,
416
+ model_settings = dict (
417
+ window_hop = args .window_hop ,
418
+ window_length = args .window_length ,
419
+ ),
394
420
n_splits = int (os .environ .get ('FOLDS' , '5' )),
395
421
features = args .features ,
396
422
)
0 commit comments