Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
C
covid_analysis
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
COMPARA
covid_analysis
Commits
87b69656
Commit
87b69656
authored
May 27, 2024
by
Joaquin Torres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Another try
parent
b682c08b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84069 additions
and
66216 deletions
+84069
-66216
model_selection/cv_metric_gen.py
model_selection/cv_metric_gen.py
+12
-15
model_selection/output_cv_metrics/curves/post_ORIG.svg
model_selection/output_cv_metrics/curves/post_ORIG.svg
+84057
-66201
model_selection/output_cv_metrics/metrics.xlsx
model_selection/output_cv_metrics/metrics.xlsx
+0
-0
No files found.
model_selection/cv_metric_gen.py
View file @
87b69656
...
@@ -209,8 +209,9 @@ if __name__ == "__main__":
...
@@ -209,8 +209,9 @@ if __name__ == "__main__":
# Curve generation setup
# Curve generation setup
mean_fpr
=
np
.
linspace
(
0
,
1
,
100
)
mean_fpr
=
np
.
linspace
(
0
,
1
,
100
)
tprs
,
aucs
=
[],
[]
tprs
,
aucs
=
[],
[]
mean_recall
=
np
.
linspace
(
0
,
1
,
100
)
recall_points
=
np
.
linspace
(
0
,
1
,
100
)
precisions
,
pr_aucs
=
[],
[]
all_precisions
=
[]
pr_aucs
=
[]
cmap
=
plt
.
get_cmap
(
'tab10'
)
# Colormap
cmap
=
plt
.
get_cmap
(
'tab10'
)
# Colormap
# Initialize storage for scores for each fold
# Initialize storage for scores for each fold
fold_scores
=
{
metric_name
:
[]
for
metric_name
in
scorings
.
keys
()}
fold_scores
=
{
metric_name
:
[]
for
metric_name
in
scorings
.
keys
()}
...
@@ -240,18 +241,14 @@ if __name__ == "__main__":
...
@@ -240,18 +241,14 @@ if __name__ == "__main__":
pr_display
=
PrecisionRecallDisplay
.
from_estimator
(
model
,
X_test_fold
,
y_test_fold
,
pr_display
=
PrecisionRecallDisplay
.
from_estimator
(
model
,
X_test_fold
,
y_test_fold
,
name
=
f
"PR fold {fold_idx}"
,
alpha
=
0.6
,
lw
=
2
,
name
=
f
"PR fold {fold_idx}"
,
alpha
=
0.6
,
lw
=
2
,
ax
=
axes
[
model_idx
][
1
],
color
=
cmap
(
fold_idx
%
10
))
ax
=
axes
[
model_idx
][
1
],
color
=
cmap
(
fold_idx
%
10
))
# Reverse the recall and precision arrays for interpolation
recall_for_interp
=
pr_display
.
recall
[::
-
1
]
precision_for_interp
=
pr_display
.
precision
[::
-
1
]
# Handle the edge case where recall_for_interp has duplicates, which can break np.interp
precision
,
recall
=
pr_display
.
precision
,
pr_display
.
recall
recall_for_interp
,
unique_indices
=
np
.
unique
(
recall_for_interp
,
return_index
=
True
)
precision_for_interp
=
precision_for_interp
[
unique_indices
]
# Interpolate precision
interp_precision
=
np
.
interp
(
mean_recall
,
recall_for_interp
,
precision_for_interp
)
precisions
.
append
(
interp_precision
)
pr_aucs
.
append
(
pr_display
.
average_precision
)
pr_aucs
.
append
(
pr_display
.
average_precision
)
axes
[
model_idx
][
1
]
.
plot
(
recall
,
precision
,
alpha
=
0.6
,
lw
=
2
,
label
=
f
"PR fold {fold_idx} (AP = {pr_display.average_precision:.2f})"
,
color
=
cmap
(
fold_idx
%
10
))
# Store the precision values for each recall point
all_precisions
.
append
(
np
.
interp
(
recall_points
,
recall
[::
-
1
],
precision
[::
-
1
]))
# Plot diagonal line for random guessing in ROC curve
# Plot diagonal line for random guessing in ROC curve
axes
[
model_idx
][
0
]
.
plot
([
0
,
1
],
[
0
,
1
],
linestyle
=
'--'
,
lw
=
2
,
color
=
'r'
,
alpha
=
.8
,
label
=
'Random guessing'
)
axes
[
model_idx
][
0
]
.
plot
([
0
,
1
],
[
0
,
1
],
linestyle
=
'--'
,
lw
=
2
,
color
=
'r'
,
alpha
=
.8
,
label
=
'Random guessing'
)
# Compute mean ROC curve
# Compute mean ROC curve
...
@@ -262,11 +259,11 @@ if __name__ == "__main__":
...
@@ -262,11 +259,11 @@ if __name__ == "__main__":
# Set ROC plot limits and title
# Set ROC plot limits and title
axes
[
model_idx
][
0
]
.
set
(
xlim
=
[
-
0.05
,
1.05
],
ylim
=
[
-
0.05
,
1.05
],
title
=
f
"ROC Curve - {model_name} ({group}-{method_names[j]})"
)
axes
[
model_idx
][
0
]
.
set
(
xlim
=
[
-
0.05
,
1.05
],
ylim
=
[
-
0.05
,
1.05
],
title
=
f
"ROC Curve - {model_name} ({group}-{method_names[j]})"
)
axes
[
model_idx
][
0
]
.
legend
(
loc
=
"lower right"
)
axes
[
model_idx
][
0
]
.
legend
(
loc
=
"lower right"
)
# Compute mean Precision-Recall curve
# Compute mean Precision-Recall curve
mean_precision
=
np
.
mean
(
precisions
,
axis
=
0
)
mean_precision
=
np
.
mean
(
all_
precisions
,
axis
=
0
)
mean_pr_auc
=
np
.
mean
(
pr_aucs
)
mean_pr_auc
=
np
.
mean
(
pr_aucs
)
axes
[
model_idx
][
1
]
.
plot
(
mean_recall
,
mean_precision
,
color
=
'b'
,
lw
=
4
,
label
=
r'Mean PR (AUC
=
%0.2
f)'
%
mean_pr_auc
,
alpha
=
.8
)
axes
[
model_idx
][
1
]
.
plot
(
recall_points
,
mean_precision
,
color
=
'b'
,
lw
=
4
,
label
=
r'Mean PR (AP
=
%0.2
f)'
%
mean_pr_auc
,
alpha
=
.8
)
# Plot baseline precision (proportion of positive samples)
# Plot baseline precision (proportion of positive samples)
baseline
=
np
.
sum
(
y_train
)
/
len
(
y_train
)
baseline
=
np
.
sum
(
y_train
)
/
len
(
y_train
)
axes
[
model_idx
][
1
]
.
plot
([
0
,
1
],
[
baseline
,
baseline
],
linestyle
=
'--'
,
lw
=
2
,
color
=
'r'
,
alpha
=
.8
,
label
=
'Baseline'
)
axes
[
model_idx
][
1
]
.
plot
([
0
,
1
],
[
baseline
,
baseline
],
linestyle
=
'--'
,
lw
=
2
,
color
=
'r'
,
alpha
=
.8
,
label
=
'Baseline'
)
...
...
model_selection/output_cv_metrics/curves/post_ORIG.svg
View file @
87b69656
This source diff could not be displayed because it is too large. You can
view the blob
instead.
model_selection/output_cv_metrics/metrics.xlsx
View file @
87b69656
No preview for this file type
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