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
7660a0e0
Commit
7660a0e0
authored
May 27, 2024
by
Joaquin Torres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trying to fix issue
parent
47aa5669
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19534 additions
and
17718 deletions
+19534
-17718
model_selection/cv_metric_gen.py
model_selection/cv_metric_gen.py
+14
-3
model_selection/output_cv_metrics/curves/post_ORIG.svg
model_selection/output_cv_metrics/curves/post_ORIG.svg
+19520
-17715
No files found.
model_selection/cv_metric_gen.py
View file @
7660a0e0
...
...
@@ -226,7 +226,7 @@ if __name__ == "__main__":
score
=
scorer
(
model
,
X_test_fold
,
y_test_fold
)
fold_scores
[
metric_name
]
.
append
(
score
)
# --------------------- END SCORINGS ---------------------------
# --------------------- CURVES ---------------------------
# --------------------- CURVES ---------------------------
# Generate ROC curve for the fold
roc_display
=
RocCurveDisplay
.
from_estimator
(
model
,
X_test_fold
,
y_test_fold
,
name
=
f
"ROC fold {fold_idx}"
,
alpha
=
0.6
,
lw
=
2
,
...
...
@@ -235,11 +235,21 @@ if __name__ == "__main__":
interp_tpr
[
0
]
=
0.0
tprs
.
append
(
interp_tpr
)
aucs
.
append
(
roc_display
.
roc_auc
)
# Generate Precision-Recall curve for the fold
pr_display
=
PrecisionRecallDisplay
.
from_estimator
(
model
,
X_test_fold
,
y_test_fold
,
name
=
f
"PR fold {fold_idx}"
,
alpha
=
0.6
,
lw
=
2
,
ax
=
axes
[
model_idx
][
1
],
color
=
cmap
(
fold_idx
%
10
))
interp_precision
=
np
.
interp
(
mean_recall
,
pr_display
.
recall
[::
-
1
],
pr_display
.
precision
[::
-
1
])
# 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
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
)
# Plot diagonal line for random guessing in ROC curve
...
...
@@ -252,6 +262,7 @@ if __name__ == "__main__":
# 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
]
.
legend
(
loc
=
"lower right"
)
# Compute mean Precision-Recall curve
mean_precision
=
np
.
mean
(
precisions
,
axis
=
0
)
mean_pr_auc
=
np
.
mean
(
pr_aucs
)
...
...
@@ -266,7 +277,7 @@ if __name__ == "__main__":
# Store the fold scores in the dataframe
for
metric_name
,
scores
in
fold_scores
.
items
():
scores_df
.
loc
[
f
"{model_name}_{metric_name}"
]
=
np
.
around
(
scores
,
4
)
# Store the DataFrame in the dictionary with a unique key for each sheet
sheet_name
=
f
"{group}_{method_names[j]}"
scores_sheets
[
sheet_name
]
=
scores_df
# Adjust layout and save figure
...
...
model_selection/output_cv_metrics/curves/post_ORIG.svg
View file @
7660a0e0
This diff is collapsed.
Click to expand it.
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