@@ -31,9 +31,9 @@ def save_plot(name: str) -> None:
31
31
BASE_PATH , os .path .join ('storage' , 'evaluation' ))
32
32
if not os .path .exists (directory_path ):
33
33
os .makedirs (directory_path )
34
- file_path : str = '%s/%s .svg' % ( directory_path , name )
34
+ file_path : str = f' { directory_path } / { name } .svg'
35
35
plt .savefig (file_path )
36
- file_path = '%s/%s .jpg' % ( directory_path , name )
36
+ file_path = f' { directory_path } / { name } .jpg'
37
37
plt .savefig (file_path )
38
38
39
39
@@ -65,7 +65,7 @@ def create_importance_plot(filename: str, importance_name: str, timed_name: bool
65
65
plot .axvline (x = 90 , color = 'red' )
66
66
trans = transforms .blended_transform_factory (
67
67
plot .get_yticklabels ()[0 ].get_transform (), plot .transData )
68
- plot .text (0.9 , - 0.025 , '{ :.0f}'. format ( 90 ) , color = 'red' , transform = trans ,
68
+ plot .text (0.9 , - 0.025 , f' { 90 :.0f} ' , color = 'red' , transform = trans ,
69
69
va = 'bottom' , ha = 'center' )
70
70
71
71
save_plot (importance_name )
@@ -106,10 +106,10 @@ def create_importance_plot_compare_regularizer(filename: str, importance_names:
106
106
plot .axvline (x = 90 , color = 'red' )
107
107
trans = transforms .blended_transform_factory (
108
108
plot .get_yticklabels ()[0 ].get_transform (), plot .transData )
109
- plot .text (0.9 , - 0.025 , '{ :.0f}'. format ( 90 ) , color = 'red' , transform = trans ,
109
+ plot .text (0.9 , - 0.025 , f' { 90 :.0f} ' , color = 'red' , transform = trans ,
110
110
va = 'bottom' , ha = 'center' )
111
111
112
- save_plot ('regularizer_compare_%s' % check_importance_type )
112
+ save_plot (f 'regularizer_compare_{ check_importance_type } ' )
113
113
114
114
if show :
115
115
plt .show ()
@@ -144,7 +144,7 @@ def create_importance_plot_compare_bn_parameter(filename: str, importance_names:
144
144
for line in plot .lines :
145
145
plt .setp (line , linewidth = 3 , alpha = 0.6 )
146
146
147
- save_plot ('bn_parameter_compare_%s' % check_importance_type )
147
+ save_plot (f 'bn_parameter_compare_{ check_importance_type } ' )
148
148
149
149
if show :
150
150
plt .show ()
@@ -157,10 +157,9 @@ def create_importance_plot_compare_class_vs_all(filename: str, importance_name:
157
157
show : bool = False ) -> None :
158
158
converted_data : List [List [Any ]] = []
159
159
160
- importance_data_name : str = '%s_[%s]' % (
161
- check_importance_type , class_index ) if class_specific_data else check_importance_type
160
+ importance_data_name : str = f'{ check_importance_type } _[{ class_index } ]' if class_specific_data else check_importance_type
162
161
overall_importance_label_name : str = 'all_classes'
163
- class_importance_label_name : str = 'class_[%s]' % class_index
162
+ class_importance_label_name : str = f 'class_[{ class_index } ]'
164
163
data : Dict [Any , Any ] = load_data (filename , importance_name , timed_name )
165
164
166
165
for percent , percent_data in data .items ():
@@ -181,8 +180,8 @@ def create_importance_plot_compare_class_vs_all(filename: str, importance_name:
181
180
plot : Axes = df .plot (legend = True )
182
181
plot .set_ylabel ('Prediction Accuracy' )
183
182
184
- save_plot ('%s_class_compare_%s_%i' %
185
- ( importance_name , check_importance_type , class_index ) )
183
+ save_plot (
184
+ f' { importance_name } _class_compare_ { check_importance_type } _ { class_index } ' )
186
185
187
186
if show :
188
187
plt .show ()
@@ -195,9 +194,8 @@ def create_importance_plot_compare_classes_vs_all(filename: str, importance_name
195
194
converted_data : List [List [Any ]] = []
196
195
197
196
for i in range (10 ):
198
- importance_data_name : str = '%s_[%s]' % (
199
- check_importance_type , i ) if class_specific_data else check_importance_type
200
- class_importance_label_name : str = "Digit \" %s\" " % i
197
+ importance_data_name : str = f'{ check_importance_type } _[{ i } ]' if class_specific_data else check_importance_type
198
+ class_importance_label_name : str = f"Digit \" { i } \" "
201
199
data : Dict [Any , Any ] = load_data (filename , importance_name , timed_name )
202
200
203
201
for percent , percent_data in data .items ():
@@ -223,7 +221,7 @@ def create_importance_plot_compare_classes_vs_all(filename: str, importance_name
223
221
for line in plot .lines :
224
222
plt .setp (line , linewidth = 3 , alpha = 0.7 )
225
223
226
- save_plot ('%s_class_compare_%s' % ( importance_name , check_importance_type ) )
224
+ save_plot (f' { importance_name } _class_compare_ { check_importance_type } ' )
227
225
228
226
if show :
229
227
plt .show ()
0 commit comments