Commit 68af3bd5 authored by Marcel Henrik Schubert's avatar Marcel Henrik Schubert
Browse files

changes in displaying analysis

parent 5b684756
......@@ -131,7 +131,7 @@ def plot_confusion_matrix(cm, classes,normalize=True,title='Confusion matrix',cm
fmt = '.2f' if normalize else 'd'
thresh = cm.max() / 2
thresh = cm.max() / 1.3
for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
ax.text(j, i, format(cm_old[i, j], fmt),
......@@ -756,7 +756,39 @@ def plotter(subsets, subana, phases, labels):
gen_pred_auth,
average='weighted').round(3)
}
gend = [comp]
ind2 = ['author by gender']
gend_an = {'accuracy': accuracy_score(df_dic[st][an]['df'].loc[df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'] == 'male'][an+'_'+str(st)+'_SVM_gender'],
df_dic[st][an]['df'].loc[df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'] == 'male'][an+'_'+str(st)+'_gender_pred_auth']).round(3),
'precision': precision_score(df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'],
gen_pred_auth, pos_label = 'male',
average='binary').round(3),
'recall': recall_score(df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'],
gen_pred_auth, pos_label = 'male',
average='binary').round(3),
'f1-score': f1_score(df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'],
gen_pred_auth, pos_label = 'male',
average='binary').round(3)
}
gend.append(gend_an)
ind2.append('author by gender\n male')
gend_an = {'accuracy': accuracy_score(df_dic[st][an]['df'].loc[df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'] == 'female'][an+'_'+str(st)+'_SVM_gender'],
df_dic[st][an]['df'].loc[df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'] == 'female'][an+'_'+str(st)+'_gender_pred_auth']).round(3),
'precision': precision_score(df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'],
gen_pred_auth, pos_label = 'female',
average='binary').round(3),
'recall': recall_score(df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'],
gen_pred_auth, pos_label = 'female',
average='binary').round(3),
'f1-score': f1_score(df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'],
gen_pred_auth, pos_label = 'female',
average='binary').round(3)
}
ind2.append('author by gender\n female')
gend.append(gend_an)
tmp.append(comp)
index.append('author by gender')
......@@ -823,6 +855,20 @@ def plotter(subsets, subana, phases, labels):
plt.tight_layout()
plt.savefig(savedir+'barplots/overall_scores_{}_{}.pdf'.format(st, an))
plt.savefig(savedir+'barplots/overall_scores_{}_{}.png'.format(st, an))
f= plt.figure(figsize=(10,5))
tmp_df =pd.DataFrame(gend, index = ind2)
tmp_df.plot(kind='barh', colormap = cmap, ax=f.gca())
plt.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
plt.xlabel(xlabel='Evaluation Measures for Different Subsets',fontsize ='large', fontweight='roman')
ax = plt.gca()
plt.setp(ax.get_xticklabels(), rotation=45, ha="right",rotation_mode="anchor")
plt.grid(True, axis ='y')
plt.ylim((0,0.7))
plt.tight_layout()
plt.savefig(savedir+'barplots/author_gender_scores_{}_{}.pdf'.format(st, an))
plt.savefig(savedir+'barplots/author_gender_scores_{}_{}.png'.format(st, an))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment