Skip to content

Commit 5436121

Browse files
committed
[ENH] made it possible to choose dataset name column to None, set to default to None
1 parent 1771270 commit 5436121

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

MCM/MCM.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_analysis(df_results,
3838
used_mean='mean-difference',
3939
order_stats='average-statistic',
4040
order_better='decreasing',
41-
dataset_column='dataset_name',):
41+
dataset_column=None,):
4242

4343
"""
4444
@@ -444,7 +444,7 @@ def get_line_heatmap(proposed_methods,
444444
colorbar_value=None,
445445
fig_size='auto',
446446
font_size='auto',
447-
pixels_per_clf_hieght=7,
447+
pixels_per_clf_hieght=8,
448448
pixels_per_clf_width=1.5,
449449
colorbar_orientation='horizontal',
450450
used_statistic='Score',
@@ -458,7 +458,7 @@ def get_line_heatmap(proposed_methods,
458458
used_mean='mean-difference',
459459
order_stats='average-statistic',
460460
order_better='decreasing',
461-
dataset_column='dataset_name',
461+
dataset_column=None,
462462
win_label='row>col',
463463
tie_label='row=col',
464464
loss_label='row<col'):
@@ -515,8 +515,8 @@ def get_line_heatmap(proposed_methods,
515515
if proposed_method not in analysis['classifier-names']:
516516
assert df_results is not None
517517

518-
load_analysis = False
519-
analysis = None
518+
load_analysis = False
519+
analysis = None
520520

521521
if not isinstance(proposed_methods, list):
522522
proposed_methods = [proposed_methods]
@@ -584,7 +584,7 @@ def _get_line_heatmap(proposed_method,
584584
used_mean='mean-difference',
585585
order_stats='average-statistic',
586586
order_better='decreasing',
587-
dataset_column='dataset_name',
587+
dataset_column=None,
588588
win_label='row>column',
589589
tie_label='row=column',
590590
loss_label='row<column'):
@@ -765,8 +765,8 @@ def _get_line_heatmap(proposed_method,
765765
_vmax = 2
766766
else:
767767
_colormap = colormap
768-
_vmin = min_value + 0.8*min_value
769-
_vmax = max_value + 0.8*max_value
768+
_vmin = min_value + 0.9*min_value
769+
_vmax = max_value + 0.9*max_value
770770

771771
if colorbar_value is None:
772772
_colorbar_value = capitalize_label('mean-difference')

MCM/utils.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@ def decode_results_data_frame(df, analysis):
3030
df_columns = list(df.columns) # extract columns from data frame
3131

3232
# check if dataset column name is correct
33-
if analysis['dataset-column'] not in df_columns:
34-
raise KeyError("The column "+analysis['dataset-column']+" is missing.")
33+
34+
if analysis['dataset-column'] is not None:
35+
if analysis['dataset-column'] not in df_columns:
36+
raise KeyError("The column "+analysis['dataset-column']+" is missing.")
3537

3638
# get number of examples (datasets)
37-
n_datasets = len(np.unique(np.asarray(df[analysis['dataset-column']])))
39+
# n_datasets = len(np.unique(np.asarray(df[analysis['dataset-column']])))
40+
n_datasets = len(df.index)
3841

3942
analysis['n-datasets'] = n_datasets # add number of examples to dictionary
4043

41-
analysis['dataset-names'] = list(df[analysis['dataset-column']]) # add example names to dict
42-
43-
df_columns.remove(analysis['dataset-column']) # drop the dataset column name from columns list
44-
# and keep classifier names
44+
if analysis['dataset-column'] is not None:
45+
46+
analysis['dataset-names'] = list(df[analysis['dataset-column']]) # add example names to dict
47+
df_columns.remove(analysis['dataset-column']) # drop the dataset column name from columns list
48+
# and keep classifier names
4549

4650
classifier_names = df_columns.copy()
4751
n_classifiers = len(classifier_names)
@@ -164,7 +168,11 @@ def re_order_classifiers(df_results, analysis):
164168

165169
elif analysis['order-stats'] == 'average-rank':
166170

167-
np_results = np.asarray(df_results.drop([analysis['dataset-column']],axis=1))
171+
if analysis['dataset-column'] is not None:
172+
np_results = np.asarray(df_results.drop([analysis['dataset-column']],axis=1))
173+
else:
174+
np_results = np.asarray(df_results)
175+
168176
df = pd.DataFrame(columns=['classifier-name','values'])
169177

170178
for i, classifier_name in enumerate(analysis['classifier-names']):

main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
if __name__ == "__main__":
66

7-
path_res = './results.csv'
7+
path_res = './results_example_no_data_column2.csv'
88
output_dir = './'
99

1010
df_results = pd.read_csv(path_res)
1111

1212
analysis = MCM.get_analysis(df_results=df_results,
1313
save_as_json=True,
1414
plot_1v1_comparisons=False,
15-
output_dir=output_dir)
15+
output_dir=output_dir,
16+
order_stats='average-rank')
1617

1718
MCM.get_heatmap(output_dir=output_dir,
1819
colormap='coolwarm',
1920
show_symetry=True)
2021

21-
MCM.get_line_heatmap(proposed_methods=['ROCKET','ResNet'],
22-
disjoint_methods=True,
23-
df_results=df_results,
22+
MCM.get_line_heatmap(proposed_methods=['clf1','clf2'],
23+
order_stats='average-rank',
2424
output_dir=output_dir)

0 commit comments

Comments
 (0)