Commit e1faeea3 authored by Marcel Henrik Schubert's avatar Marcel Henrik Schubert
Browse files

analysis...seaborn heatmaps

parent 557112ba
......@@ -638,7 +638,16 @@ def plotter(subsets, subana, phases, labels):
an=an,
label=label,
group='life_phase'))
f = plt.figure()
ax = f.subplots()
cm = cnf_matrix.astype('float') / cnf_matrix.sum(axis=1)[:, np.newaxis]
sns.heatmap(cm, vmin=0, vmax=1, cmap= plt.cm.Blues, center = 0.0, annot = cnf_matrix, fmt = 'd', cbar = True,
cbar_kws= {'label': "Heat per Row (Normalized)"}, square = True, xticklabels = phases, yticklabels= phases, ax=ax)
f.savefig(savedir+ 'heatmaps/cm_{st}_{an}_{label}_{group}_seaborn.pdf'.format(st = st,
an=an,
label=label,
group='life_phase'))
......@@ -724,7 +733,7 @@ def plotter(subsets, subana, phases, labels):
plot_confusion_matrix(cnf_matrix, classes=phases,title=None, ax=ax)
plt.show()
#plt.show()
plt.tight_layout()
f.savefig(savedir+'heatmaps/cm_{st}_{an}_{label}_{group}.pdf'.format(st = st, an=an,
label=label,
......@@ -732,6 +741,18 @@ def plotter(subsets, subana, phases, labels):
f.savefig(savedir+'heatmaps/cm_{st}_{an}_{label}_{group}.png'.format(st = st, an=an,
label=label,
group='life_phase'))
f = plt.figure()
ax = f.subplots()
cm = cnf_matrix.astype('float') / cnf_matrix.sum(axis=1)[:, np.newaxis]
sns.heatmap(cm, vmin=0, vmax=1, cmap= plt.cm.Blues, center = 0.0, annot = cnf_matrix, fmt = 'd', cbar = True,
cbar_kws= {'label': "Heat per Row (Normalized)"}, square = True, xticklabels = phases, yticklabels= phases, ax=ax)
f.savefig(savedir+ 'heatmaps/cm_{st}_{an}_{label}_{group}_seaborn.pdf'.format(st = st,
an=an,
label=label,
group='life_phase'))
comp = {'accuracy': accuracy_score(df_dic[st][an]['df'][an+'_'+str(st)+'_SVM_gender'],
gen_pred_auth).round(3),
......@@ -795,6 +816,15 @@ def plotter(subsets, subana, phases, labels):
label=label,
group='gender'))
f = plt.figure()
ax = f.subplots()
cm = cnf_matrix.astype('float') / cnf_matrix.sum(axis=1)[:, np.newaxis]
sns.heatmap(cm, vmin=0, vmax=1, cmap= plt.cm.Blues, center = 0.0, annot = cnf_matrix, fmt = 'd', cbar = True,
cbar_kws= {'label': "Heat per Row (Normalized)"}, square = True, xticklabels = phases, yticklabels= phases, ax=ax)
f.savefig(savedir+ 'heatmaps/cm_{st}_{an}_{label}_{group}_seaborn.pdf'.format(st = st,
an=an,
label=label,
group='life_phase'))
###make author cmap showing whether the author missclassified
##were confused with authors of similar gender or life_phase
cnf_matrix = confusion_matrix(sub_wrong[an+'_'+str(st)+'_life_phase'],
......@@ -811,7 +841,17 @@ def plotter(subsets, subana, phases, labels):
label=label,
group='life_phase'))
f = plt.figure()
ax = f.subplots()
cm = cnf_matrix.astype('float') / cnf_matrix.sum(axis=1)[:, np.newaxis]
sns.heatmap(cm, vmin=0, vmax=1, cmap= plt.cm.Blues, center = 0.0, annot = cnf_matrix, fmt = 'd', cbar = True,
cbar_kws= {'label': "Heat per Row (Normalized)"}, square = True, xticklabels = phases, yticklabels= phases, ax=ax)
f.savefig(savedir+ 'heatmaps/cm_{st}_{an}_{label}_{group}_seaborn.pdf'.format(st = st,
an=an,
label=label,
group='life_phase'))
cnf_matrix = confusion_matrix(sub_wrong[an+'_'+str(st)+'_SVM_gender'],
gen_pred_auth_wrong,
labels=['female', 'male'])
......@@ -825,7 +865,15 @@ def plotter(subsets, subana, phases, labels):
f.savefig(savedir+'heatmaps/cm_{st}_{an}_{label}_{group}_false.png'.format(st = st, an=an,
label=label,
group='gender'))
f = plt.figure()
ax = f.subplots()
cm = cnf_matrix.astype('float') / cnf_matrix.sum(axis=1)[:, np.newaxis]
sns.heatmap(cm, vmin=0, vmax=1, cmap= plt.cm.Blues, center = 0.0, annot = cnf_matrix, fmt = 'd', cbar = True,
cbar_kws= {'label': "Heat per Row (Normalized)"}, square = True, xticklabels = phases, yticklabels= phases, ax=ax)
f.savefig(savedir+ 'heatmaps/cm_{st}_{an}_{label}_{group}_seaborn.pdf'.format(st = st,
an=an,
label=label,
group='life_phase'))
......
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