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
3a64c388
Commit
3a64c388
authored
Jun 27, 2024
by
Joaquin Torres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paths updated model_selection
parent
941fd4ed
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
8 deletions
+7
-8
model_selection/cv_metric_gen.py
model_selection/cv_metric_gen.py
+2
-3
model_selection/cv_metrics_distr.py
model_selection/cv_metrics_distr.py
+1
-1
model_selection/hyperparam_tuning.py
model_selection/hyperparam_tuning.py
+1
-1
model_selection/test_models.py
model_selection/test_models.py
+3
-3
No files found.
model_selection/cv_metric_gen.py
View file @
3a64c388
...
...
@@ -272,15 +272,14 @@ 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
)
sheet_name
=
f
"{group}_{method_names[j]}"
scores_sheets
[
sheet_name
]
=
scores_df
# Adjust layout and save figure
plt
.
tight_layout
()
plt
.
savefig
(
f
'./output
_
cv_metrics/curves/{group}_{method_names[j]}.svg'
,
format
=
'svg'
,
dpi
=
500
)
plt
.
savefig
(
f
'./output
/
cv_metrics/curves/{group}_{method_names[j]}.svg'
,
format
=
'svg'
,
dpi
=
500
)
plt
.
close
(
fig
)
# Write results to Excel file
with
pd
.
ExcelWriter
(
'./output
_
cv_metrics/metrics.xlsx'
)
as
writer
:
with
pd
.
ExcelWriter
(
'./output
./
cv_metrics/metrics.xlsx'
)
as
writer
:
for
sheet_name
,
data
in
scores_sheets
.
items
():
data
.
to_excel
(
writer
,
sheet_name
=
sheet_name
)
print
(
"Successful cv metric generation for tuned models"
)
...
...
model_selection/cv_metrics_distr.py
View file @
3a64c388
...
...
@@ -44,7 +44,7 @@ if __name__ == "__main__":
if
metric_name
in
[
'F1'
,
'PREC'
,
'REC'
,
'ACC'
,
'AUROC'
,
'AUPRC'
]:
ax
.
set_ylim
(
0
,
1
)
plt
.
tight_layout
()
fig
.
savefig
(
f
'./output
_
cv_metrics/distributions/{group}{method}.svg'
,
format
=
'svg'
,
dpi
=
600
)
fig
.
savefig
(
f
'./output
/
cv_metrics/distributions/{group}{method}.svg'
,
format
=
'svg'
,
dpi
=
600
)
plt
.
close
(
fig
)
# Close the figure to free up memory
print
(
"Succesful distribution plots generation"
)
...
...
model_selection/hyperparam_tuning.py
View file @
3a64c388
...
...
@@ -159,7 +159,7 @@ if __name__ == "__main__":
sheets_dict
[
sheet_name
]
=
hyperparam_df
# Write results to Excel file
with
pd
.
ExcelWriter
(
'./output
_
hyperparam/hyperparamers.xlsx'
)
as
writer
:
with
pd
.
ExcelWriter
(
'./output
/
hyperparam/hyperparamers.xlsx'
)
as
writer
:
for
sheet_name
,
data
in
sheets_dict
.
items
():
data
.
to_excel
(
writer
,
sheet_name
=
sheet_name
)
...
...
model_selection/test_models.py
View file @
3a64c388
...
...
@@ -77,7 +77,7 @@ def read_data():
def
get_tuned_models
(
group_str
,
method_str
):
# Read sheet corresponding to group and method with tuned models and their hyperparam
tuned_models_df
=
pd
.
read_excel
(
"./output
_
hyperparam/hyperparamers.xlsx"
,
sheet_name
=
f
"{group_str}_{method_str}"
)
tuned_models_df
=
pd
.
read_excel
(
"./output
/
hyperparam/hyperparamers.xlsx"
,
sheet_name
=
f
"{group_str}_{method_str}"
)
# Mapping from model abbreviations to sklearn model classes
model_mapping
=
{
'DT'
:
DecisionTreeClassifier
,
...
...
@@ -274,13 +274,13 @@ if __name__ == "__main__":
# ----------------------------------------------------------
# Adjust layout and save/show figure
plt
.
tight_layout
()
plt
.
savefig
(
f
'./output
_test
/plots/{group}_{method_names[j]}.svg'
,
format
=
'svg'
,
dpi
=
500
)
plt
.
savefig
(
f
'./output
/testing
/plots/{group}_{method_names[j]}.svg'
,
format
=
'svg'
,
dpi
=
500
)
plt
.
close
(
fig
)
# 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
# Write results to Excel file
with
pd
.
ExcelWriter
(
'./output
_test
/testing_tuned_models.xlsx'
)
as
writer
:
with
pd
.
ExcelWriter
(
'./output
/testing
/testing_tuned_models.xlsx'
)
as
writer
:
for
sheet_name
,
data
in
scores_sheets
.
items
():
data
.
to_excel
(
writer
,
sheet_name
=
sheet_name
)
print
(
"Successful evaluation with test dataset"
)
...
...
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