Commit 9b9225ce authored by Leonie Pick's avatar Leonie Pick

Changes to plot for decision boundary

parent d35973ac
This diff is collapsed.
......@@ -816,7 +816,7 @@ def Assess_Model(Data,Target,N2,K2,modelTest0,n_classes,Plot,Save,SaveName):
## Calibration curve
Calib[i,ii,2,:], bin_edges = np.histogram(proba_test[:,1], bins=np.arange(0,1.1,0.1))
# My way for calibration curve:
# #My way for calibration curve:
# for iii in range(len(bin_edges)-1):
# if iii == len(bin_edges)-2:
# indices = np.logical_and(proba_test[:,1] >= bin_edges[iii],proba_test[:,1] <= bin_edges[iii+1])
......@@ -858,14 +858,17 @@ def Assess_Model(Data,Target,N2,K2,modelTest0,n_classes,Plot,Save,SaveName):
decision_boundary_MCC = int(thresholds[np.nanargmax(Model_Mean[19,0,:])]*100)
decision_boundary_MCC_train = int(thresholds[np.nanargmax(Model_Mean[19,1,:])]*100)
scores_mean = np.nanmean(Model_Mean[[11,15,18,19,20],0,:],axis=0)
scores_mean_2 = np.nanmean(Model_Mean[[11,15,18,19,20,21],0,:],axis=0)
scores_mean_train = np.nanmean(Model_Mean[[11,15,18,19,20],1,:],axis=0)
decision_boundary_all = int(thresholds[np.nanargmax(scores_mean)]*100)
decision_boundary_all_2 = int(thresholds[np.nanargmax(scores_mean_2)]*100)
decision_boundary_all_train = int(thresholds[np.nanargmax(scores_mean_train)]*100)
decision_boundary = 50
#decision_boundary = decision_boundary_all
#print('best MCC:',np.nanmax(Model_Mean[19,0,:]))
print('best decision test:',thresholds[decision_boundary_MCC], thresholds[decision_boundary_all])
print('best decision test 2:',thresholds[decision_boundary_MCC], thresholds[decision_boundary_all_2])
print('best decision train:',thresholds[decision_boundary_MCC_train], thresholds[decision_boundary_all_train])
C, Scores = Get_MyScores(CM_means[:,0,decision_boundary], n_classes)
......
......@@ -617,15 +617,25 @@ def Decision(thresholds,Model_Mean,Model_Std,Save,SaveName):
fig.subplots_adjust(bottom=0.1,top=0.95,left=0.15,right=0.95,wspace=0.0,hspace=0.0)
axs.axis('equal')
scoreID = [11,15,18,19,20,21]
scoreLabel = ['ACC','F1','HSS','MCC','J','Deltap']
scoreID = [11,15,18,19,20]#,21]
scoreLabel = ['ACC','F1','HSS','MCC','J']#,'Deltap']
linewidth=[.5,.5,.5,1.5,.5,.5]
zorder=[0,0,0,1,0,0]
colors=['midnightblue','orange','magenta','maroon','green','purple']
colors=['midnightblue','orange','magenta','maroon','green']#,'purple']
for i in range(len(scoreID)):
#axs[0].plot(thresholds, Model_Mean[scoreID[i],:],label=scoreLabel[i])
axs.errorbar(thresholds, Model_Mean[scoreID[i],:], yerr=3*Model_Std[scoreID[i],:], fmt='none',elinewidth=linewidth[i], ecolor=colors[i], zorder=0)
axs.plot(thresholds, Model_Mean[scoreID[i],:], linewidth=linewidth[i], color=colors[i], zorder=zorder[i], label=scoreLabel[i]+r'$\pm$3$\cdot$std')
axs.errorbar(thresholds, Model_Mean[scoreID[i],:], yerr=Model_Std[scoreID[i],:], fmt='none',elinewidth=linewidth[i], ecolor=colors[i], zorder=0)
axs.plot(thresholds, Model_Mean[scoreID[i],:], linewidth=linewidth[i], color=colors[i], zorder=zorder[i], label=scoreLabel[i]+r' $\pm$ std')
scores_mean = np.nanmean(Model_Mean[scoreID,:],axis=0)
decision_boundary_all = thresholds[np.nanargmax(scores_mean)]
decision_boundary_MCC = thresholds[np.nanargmax(Model_Mean[19,:])]
axs.plot(np.zeros(100)+decision_boundary_all,np.linspace(0,np.nanmax(scores_mean),100), linewidth=1.0, linestyle='--', color='black')
axs.plot(np.linspace(0,decision_boundary_all,100),np.zeros(100)+np.nanmax(scores_mean), linewidth=1.0, linestyle='--', color='black')
axs.plot(np.zeros(100)+decision_boundary_MCC,np.linspace(0,np.nanmax(Model_Mean[19,:]),100), linewidth=1.0, linestyle='--', color='dimgray')
axs.plot(np.linspace(0,decision_boundary_MCC,100),np.zeros(100)+np.nanmax(Model_Mean[19,:]), linewidth=1.0, linestyle='--', color='dimgray')
axs.set_xlim([0,1]); axs.set_ylim([0,1])
axs.set_xticks(np.linspace(0,1,11))
axs.set_xticks(np.linspace(0,1,21),minor='True')
......
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