@@ -512,31 +512,6 @@ def gen_basic_dict(library, algorithm, stage, params, data, alg_instance=None,
512
512
return result
513
513
514
514
515
- def update_result_dict (result ) -> None :
516
- result .update ({'time[s]' : times [i ]})
517
- if metric_type is not None :
518
- if isinstance (metric_type , str ):
519
- result .update ({f'{ metric_type } ' : metrics [i ]})
520
- elif isinstance (metric_type , list ):
521
- for ind , val in enumerate (metric_type ):
522
- if metrics [ind ][i ] is not None :
523
- result .update ({f'{ val } ' : metrics [ind ][i ]})
524
- if hasattr (params , 'n_classes' ):
525
- result ['input_data' ].update ({'classes' : params .n_classes })
526
- if hasattr (params , 'n_clusters' ):
527
- if algorithm == 'kmeans' :
528
- result ['input_data' ].update (
529
- {'n_clusters' : params .n_clusters })
530
- elif algorithm == 'dbscan' :
531
- result .update ({'n_clusters' : params .n_clusters })
532
- # replace non-string init with string for kmeans benchmarks
533
- if alg_instance is not None :
534
- if 'init' in result ['algorithm_parameters' ].keys ():
535
- if not isinstance (result ['algorithm_parameters' ]['init' ], str ):
536
- result ['algorithm_parameters' ]['init' ] = 'random'
537
- if 'handle' in result ['algorithm_parameters' ].keys ():
538
- del result ['algorithm_parameters' ]['handle' ]
539
-
540
515
def print_output (library , algorithm , stages , params , functions ,
541
516
times , metric_type , metrics , data , alg_instance = None ,
542
517
alg_params = None ):
@@ -546,30 +521,27 @@ def print_output(library, algorithm, stages, params, functions,
546
521
for i , stage in enumerate (stages ):
547
522
result = gen_basic_dict (library , algorithm , stage , params ,
548
523
data [i ], alg_instance , alg_params )
549
- update_result_dict (result )
550
- # result.update({'time[s]': times[i]})
551
- # if metric_type is not None:
552
- # if isinstance(metric_type, str):
553
- # result.update({f'{metric_type}': metrics[i]})
554
- # elif isinstance(metric_type, list):
555
- # for ind, val in enumerate(metric_type):
556
- # if metrics[ind][i] is not None:
557
- # result.update({f'{val}': metrics[ind][i]})
558
- # if hasattr(params, 'n_classes'):
559
- # result['input_data'].update({'classes': params.n_classes})
560
- # if hasattr(params, 'n_clusters'):
561
- # if algorithm == 'kmeans':
562
- # result['input_data'].update(
563
- # {'n_clusters': params.n_clusters})
564
- # elif algorithm == 'dbscan':
565
- # result.update({'n_clusters': params.n_clusters})
566
- # # replace non-string init with string for kmeans benchmarks
567
- # if alg_instance is not None:
568
- # if 'init' in result['algorithm_parameters'].keys():
569
- # if not isinstance(result['algorithm_parameters']['init'], str):
570
- # result['algorithm_parameters']['init'] = 'random'
571
- # if 'handle' in result['algorithm_parameters'].keys():
572
- # del result['algorithm_parameters']['handle']
524
+ result .update ({'time[s]' : times [i ]})
525
+ if isinstance (metric_type , str ):
526
+ result .update ({f'{ metric_type } ' : metrics [i ]})
527
+ elif isinstance (metric_type , list ):
528
+ for ind , val in enumerate (metric_type ):
529
+ if metrics [ind ][i ] is not None :
530
+ result .update ({f'{ val } ' : metrics [ind ][i ]})
531
+ if hasattr (params , 'n_classes' ):
532
+ result ['input_data' ].update ({'classes' : params .n_classes })
533
+ if hasattr (params , 'n_clusters' ):
534
+ if algorithm == 'kmeans' :
535
+ result ['input_data' ].update (
536
+ {'n_clusters' : params .n_clusters })
537
+ elif algorithm == 'dbscan' :
538
+ result .update ({'n_clusters' : params .n_clusters })
539
+ # replace non-string init with string for kmeans benchmarks
540
+ if alg_instance is not None :
541
+ if 'init' in result ['algorithm_parameters' ].keys ():
542
+ if not isinstance (result ['algorithm_parameters' ]['init' ], str ):
543
+ result ['algorithm_parameters' ]['init' ] = 'random'
544
+ result ['algorithm_parameters' ].pop ('handle' ,None )
573
545
output .append (result )
574
546
print (json .dumps (output , indent = 4 ))
575
547
0 commit comments