Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
ClassifyStorms
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Leonie Pick
ClassifyStorms
Commits
32773479
Commit
32773479
authored
Jul 31, 2019
by
Leonie Pick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Included decision boundary in ROC and P-R curves
parent
4f833d33
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
233 additions
and
201 deletions
+233
-201
.ipynb_checkpoints/ClassifyStorms-checkpoint.ipynb
.ipynb_checkpoints/ClassifyStorms-checkpoint.ipynb
+95
-131
ClassifyStorms.ipynb
ClassifyStorms.ipynb
+119
-56
Modules.py
Modules.py
+3
-1
Plots.py
Plots.py
+16
-13
No files found.
.ipynb_checkpoints/ClassifyStorms-checkpoint.ipynb
View file @
32773479
This diff is collapsed.
Click to expand it.
ClassifyStorms.ipynb
View file @
32773479
This diff is collapsed.
Click to expand it.
Modules.py
View file @
32773479
...
...
@@ -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
###
...
...
Plots.py
View file @
32773479
...
...
@@ -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'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment