@@ -389,14 +389,13 @@ def convert_data(data, dtype, data_order, data_format):
389
389
# Secondly, change format of data
390
390
if data_format == 'numpy' :
391
391
return data
392
- elif data_format == 'pandas' :
392
+ if data_format == 'pandas' :
393
393
import pandas as pd
394
394
395
395
if data .ndim == 1 :
396
396
return pd .Series (data )
397
- else :
398
- return pd .DataFrame (data )
399
- elif data_format == 'cudf' :
397
+ return pd .DataFrame (data )
398
+ if data_format == 'cudf' :
400
399
import cudf
401
400
import pandas as pd
402
401
@@ -439,16 +438,24 @@ def load_data(params, generated_data=[], add_dtype=False, label_2d=False,
439
438
for element in full_data :
440
439
file_arg = f'file_{ element } '
441
440
# load and convert data from npy/csv file if path is specified
441
+ new_dtype = int_dtype if 'y' in element and int_label else params .dtype
442
442
if param_vars [file_arg ] is not None :
443
443
if param_vars [file_arg ].name .endswith ('.npy' ):
444
444
data = np .load (param_vars [file_arg ].name , allow_pickle = True )
445
445
else :
446
446
data = read_csv (param_vars [file_arg ].name , params )
447
447
full_data [element ] = convert_data (
448
448
data ,
449
- int_dtype if 'y' in element and int_label else params . dtype ,
449
+ new_dtype ,
450
450
params .data_order , params .data_format
451
451
)
452
+ if full_data [element ] is None :
453
+ # generate and convert data if it's marked and path isn't specified
454
+ if element in generated_data :
455
+ full_data [element ] = convert_data (
456
+ np .random .rand (* params .shape ),
457
+ new_dtype ,
458
+ params .data_order , params .data_format )
452
459
# generate and convert data if it's marked and path isn't specified
453
460
if full_data [element ] is None and element in generated_data :
454
461
full_data [element ] = convert_data (
@@ -522,13 +529,12 @@ def print_output(library, algorithm, stages, params, functions,
522
529
result = gen_basic_dict (library , algorithm , stage , params ,
523
530
data [i ], alg_instance , alg_params )
524
531
result .update ({'time[s]' : times [i ]})
525
- if metric_type is not None :
526
- if isinstance (metric_type , str ):
527
- result .update ({f'{ metric_type } ' : metrics [i ]})
528
- elif isinstance (metric_type , list ):
529
- for ind , val in enumerate (metric_type ):
530
- if metrics [ind ][i ] is not None :
531
- result .update ({f'{ val } ' : metrics [ind ][i ]})
532
+ if isinstance (metric_type , str ):
533
+ result .update ({f'{ metric_type } ' : metrics [i ]})
534
+ elif isinstance (metric_type , list ):
535
+ for ind , val in enumerate (metric_type ):
536
+ if metrics [ind ][i ] is not None :
537
+ result .update ({f'{ val } ' : metrics [ind ][i ]})
532
538
if hasattr (params , 'n_classes' ):
533
539
result ['input_data' ].update ({'classes' : params .n_classes })
534
540
if hasattr (params , 'n_clusters' ):
@@ -542,8 +548,7 @@ def print_output(library, algorithm, stages, params, functions,
542
548
if 'init' in result ['algorithm_parameters' ].keys ():
543
549
if not isinstance (result ['algorithm_parameters' ]['init' ], str ):
544
550
result ['algorithm_parameters' ]['init' ] = 'random'
545
- if 'handle' in result ['algorithm_parameters' ].keys ():
546
- del result ['algorithm_parameters' ]['handle' ]
551
+ result ['algorithm_parameters' ].pop ('handle' , None )
547
552
output .append (result )
548
553
print (json .dumps (output , indent = 4 ))
549
554
0 commit comments