Commit 32773479 authored by Leonie Pick's avatar Leonie Pick

Included decision boundary in ROC and P-R curves

parent 4f833d33
This diff is collapsed.
......@@ -720,6 +720,8 @@ def Assess_Model(Data,Target,N2,K2,modelTest,n_classes,Plot,Save,SaveName):
## ROC, Precision-Recall curves, confusion matrix
curve_i = np.linspace(0,1,100)
#curve_i = np.linspace(0,1,101)
Curves = np.zeros((N2,K2,2,100))
CM = np.zeros((N2,K2,n_classes**2,2))
......@@ -784,7 +786,7 @@ def Assess_Model(Data,Target,N2,K2,modelTest,n_classes,Plot,Save,SaveName):
# Plot mean confusion matrix and curves
if Plot == True:
pl.CM(CM_means[:,0],C,n_classes,Save,SaveName)
pl.Curves(N2,K2,Curves,curve_i,Model_Mean[0:2,0],Model_Std[0:2,0],C,Save,SaveName)
pl.Curves(N2,K2,Curves,curve_i,Model_Mean[2:7,0],Model_Mean[0:2,0],Model_Std[0:2,0],C,Save,SaveName)
return Model_Mean, Model_Std
###
......
......@@ -86,8 +86,8 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
HMC_step = 7.78
HMC_range = np.arange(10,480+HMC_step,HMC_step)
Index_range = HMC_range #Kp_range
step = HMC_step #Kp_step
Index_range = Kp_range #HMC_range
step = Kp_step #HMC_step
years = np.arange(1932,2016,1)
Percentages = np.zeros((len(years),len(Index_range)))
......@@ -123,11 +123,11 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
HMCValues = -HMC[Storms[StormsBlock]]
#KpValuesAll.extend(KpValues.tolist())
#Hist[l,:], bin_edges = np.histogram(KpValues, bins = Index_range)
KpValuesAll.extend(KpValues.tolist())
Hist[l,:], bin_edges = np.histogram(KpValues, bins = Index_range)
KpValuesAll.extend(HMCValues.tolist())
Hist[l,:], bin_edges = np.histogram(HMCValues, bins = Index_range)
#KpValuesAll.extend(HMCValues.tolist())
#Hist[l,:], bin_edges = np.histogram(HMCValues, bins = Index_range)
Hist[l,:] *= 100/len(Storms1932)
......@@ -173,13 +173,13 @@ def IndexDist(Time,YearsIndex,Storms,Kp_all,KpHours_all,HMC,Save):
ax2.legend(loc=4,ncol=1,frameon=False,fontsize=10)
ax2.set_ylabel('Occurrence [%]')
#ax2.set_xticklabels(np.arange(0,10,1))
#ax2.set_xlabel('Kp')
#ax2.set_ylim([0,10])
ax2.set_xticklabels(np.arange(0,10,1))
ax2.set_xlabel('Kp')
ax2.set_ylim([0,10])
ax2.set_xticklabels(np.around(Index_range[::3]/100,1))
ax2.set_xlabel('-HMC/100 [nT]')
ax2.set_ylim([0,20])
#ax2.set_xticklabels(np.around(Index_range[::3]/100,1))
#ax2.set_xlabel('-HMC/100 [nT]')
#ax2.set_ylim([0,20])
#ax3.fill_between(np.arange(0,len(Kp_range)-1,1)+0.5,CumSum,CumSum2,color='maroon')
#ax3.set_ylim([0,105])
......@@ -389,7 +389,7 @@ def CM(CM,Condition,n_classes,Save,SaveName):
plt.show()
###
###
def Curves(N2,K2,Curves,curve_i,Model_Mean,Model_Std,C,Save,SaveName):
def Curves(N2,K2,Curves,curve_i,Scorers,Model_Mean,Model_Std,C,Save,SaveName):
fig, axs = plt.subplots(1,2,facecolor='w',edgecolor='k',sharey=True)
fig.set_size_inches([14,6], forward=True)
......@@ -426,6 +426,9 @@ def Curves(N2,K2,Curves,curve_i,Model_Mean,Model_Std,C,Save,SaveName):
axs[0].plot(curve_i,ROC_outer,color='maroon',label='Total mean',zorder=2)
axs[1].plot(curve_i,PR_outer,color='maroon',label='Total mean',zorder=2)
axs[0].scatter(Scorers[2],Scorers[0],s=40,color='blue',label='Decision boundary',zorder=3)
axs[1].scatter(Scorers[0],Scorers[4],s=40,color='blue',label='Decision boundary',zorder=3)
P = C[1,0]; PP = C[1,1]; N = C[0,0]; PN = C[0,1]; POP = sum(C[:,0])
#P,PP,N,PN = C
axs[0].plot([0,1],[0,1],linestyle='--',color='midnightblue',label='Chance')
......
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