@@ -64,7 +64,7 @@ def plot_calibration(bin_true_prob, bin_pred_prob, zf_name):
6464 ax1 .plot (bin_pred_prob , bin_true_prob , "s-" , color = '#02124D' ,
6565 label = "model" )
6666
67- ax1 .set_ylabel ("Fraction of loans that resolve " , fontsize = 14 )
67+ ax1 .set_ylabel ("Fraction of Positives " , fontsize = 14 )
6868 ax1 .set_ylim ([- 0.05 , 1.05 ])
6969 ax1 .legend (loc = "lower right" , fontsize = 12 )
7070 ax1 .set_title ('Model Calibration (reliability curve)' , fontsize = 16 )
@@ -78,6 +78,7 @@ def plot_calibration(bin_true_prob, bin_pred_prob, zf_name):
7878
7979# plot heatmap
8080def plot_heatmap (corr_values , feature_names , zf_name ):
81+ plt .figure (figsize = (9 , 8 ))
8182 ax = sns .heatmap (
8283 corr_values ,
8384 vmin = - 1 , vmax = 1 , center = 0 ,
@@ -86,7 +87,7 @@ def plot_heatmap(corr_values, feature_names, zf_name):
8687 )
8788 ax .set_xticklabels (
8889 feature_names ,
89- rotation = 25 ,
90+ rotation = 45 ,
9091 horizontalalignment = 'right'
9192 )
9293 ax .set_yticklabels (
@@ -127,11 +128,11 @@ def plot_weighted_confusion_matrix(values, name1, name2, zf_name):
127128
128129
129130# Plot contour
130- def plot_contour (zf_name , key ):
131+ def plot_contour (zf_name , key , fair_metric_name , perf_metric_name ):
131132 plt .figure (figsize = (9 , 8 ))
132133# plt.title('Fairness vs. Performance Tradeoffs', fontsize=18)
133- plt .xlabel ('Lending Threshold Privileged' , fontsize = 16 )
134- plt .ylabel ('Lending Threshold Unprivileged' , fontsize = 16 )
134+ plt .xlabel (key + ' Threshold Privileged' , fontsize = 16 )
135+ plt .ylabel (key + ' Threshold Unprivileged' , fontsize = 16 )
135136 plt .xlim (np .min (th_a ), np .max (th_a ))
136137 plt .ylim (np .min (th_b ), np .max (th_b ))
137138
@@ -208,7 +209,7 @@ def plot_contour(zf_name, key):
208209perf_dynamic = data ['perf_dynamic' ]
209210
210211# plot weighted_confusion_matrix
211- plot_weighted_confusion_matrix (weighted_confusion_matrix_list , ['Default ' , 'Repay ' ], ['Default ' , 'Repay ' ], zf_name )
212+ plot_weighted_confusion_matrix (weighted_confusion_matrix_list , ['Negative ' , 'Positive ' ], ['Negative ' , 'Positive ' ], zf_name )
212213
213214# plot class distribution
214215plot_piechart (class_distribution_list , class_distribution_label , zf_name , '' )
@@ -222,6 +223,10 @@ def plot_contour(zf_name, key):
222223# plot perf dynamic
223224plot_perf_dynamic (perf_dynamic ['threshold' ], perf_dynamic ['perf' ], perf_dynamic ['selection_rate' ], zf_name )
224225for key in features_dict :
226+ fair_metric_name = features_dict [key ]['tradeoff' ]['fair_metric_name' ]
227+ perf_metric_name = features_dict [key ]['tradeoff' ]['perf_metric_name' ]
228+ fair_metric_name = re .sub ('_' , ' ' , fair_metric_name )
229+ perf_metric_name = re .sub ('_' , ' ' , perf_metric_name )
225230 th_a = features_dict [key ]['tradeoff' ]['th_x' ]
226231 th_b = features_dict [key ]['tradeoff' ]['th_y' ]
227232 perf = np .array (features_dict [key ]['tradeoff' ]['perf' ])
@@ -235,6 +240,6 @@ def plot_contour(zf_name, key):
235240 # plot feature_distribution
236241 plot_piechart (feature_distribution_list , feature_distribution_label , zf_name , key )
237242 # plot contour
238- plot_contour (zf_name , key )
243+ plot_contour (zf_name , key , fair_metric_name , perf_metric_name )
239244
240245print (json .dumps (image_file_list ))
0 commit comments