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
c180f1dd
Commit
c180f1dd
authored
May 09, 2024
by
Joaquin Torres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tuned PRE under
parent
df047659
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
model_selection/hyperparam_tuning.py
model_selection/hyperparam_tuning.py
+4
-4
model_selection/output/hyperparam_pre_UNDER.xlsx
model_selection/output/hyperparam_pre_UNDER.xlsx
+0
-0
No files found.
model_selection/hyperparam_tuning.py
View file @
c180f1dd
...
@@ -143,7 +143,7 @@ if __name__ == "__main__":
...
@@ -143,7 +143,7 @@ if __name__ == "__main__":
# Store each df as a sheet in an excel file
# Store each df as a sheet in an excel file
sheets_dict
=
{}
sheets_dict
=
{}
for
i
,
group
in
enumerate
([
'pre'
]):
for
i
,
group
in
enumerate
([
'pre'
]):
for
j
,
method
in
enumerate
([
'
ov
er_'
]):
#['', '', 'over_', 'under_']
for
j
,
method
in
enumerate
([
'
und
er_'
]):
#['', '', 'over_', 'under_']
# Get dataset based on group and method
# Get dataset based on group and method
X
=
data_dic
[
'X_train_'
+
method
+
group
]
X
=
data_dic
[
'X_train_'
+
method
+
group
]
y
=
data_dic
[
'y_train_'
+
method
+
group
]
y
=
data_dic
[
'y_train_'
+
method
+
group
]
...
@@ -153,7 +153,7 @@ if __name__ == "__main__":
...
@@ -153,7 +153,7 @@ if __name__ == "__main__":
# Save results: params and best score for each of the mdodels of this method and group
# Save results: params and best score for each of the mdodels of this method and group
hyperparam_df
=
pd
.
DataFrame
(
index
=
list
(
models
.
keys
()),
columns
=
[
'Parameters'
,
'Score'
])
hyperparam_df
=
pd
.
DataFrame
(
index
=
list
(
models
.
keys
()),
columns
=
[
'Parameters'
,
'Score'
])
for
model_name
,
model
in
models
.
items
():
for
model_name
,
model
in
models
.
items
():
print
(
f
"{group}-{method_names[
2
]}-{model_name}"
)
print
(
f
"{group}-{method_names[
3
]}-{model_name}"
)
# Find optimal hyperparams for curr model
# Find optimal hyperparams for curr model
params
=
hyperparameters
[
model_name
]
params
=
hyperparameters
[
model_name
]
search
=
RandomizedSearchCV
(
model
,
param_distributions
=
params
,
cv
=
cv
,
n_jobs
=
8
,
scoring
=
'precision'
)
search
=
RandomizedSearchCV
(
model
,
param_distributions
=
params
,
cv
=
cv
,
n_jobs
=
8
,
scoring
=
'precision'
)
...
@@ -162,11 +162,11 @@ if __name__ == "__main__":
...
@@ -162,11 +162,11 @@ if __name__ == "__main__":
hyperparam_df
.
at
[
model_name
,
'Score'
]
=
round
(
search
.
best_score_
,
4
)
hyperparam_df
.
at
[
model_name
,
'Score'
]
=
round
(
search
.
best_score_
,
4
)
# Store the DataFrame in the dictionary with a unique key for each sheet
# Store the DataFrame in the dictionary with a unique key for each sheet
sheet_name
=
f
"{group}_{method_names[
j
]}"
sheet_name
=
f
"{group}_{method_names[
3
]}"
sheets_dict
[
sheet_name
]
=
hyperparam_df
sheets_dict
[
sheet_name
]
=
hyperparam_df
# Write results to Excel file
# Write results to Excel file
with
pd
.
ExcelWriter
(
'./output/hyperparam_pre_
OV
ER.xlsx'
)
as
writer
:
with
pd
.
ExcelWriter
(
'./output/hyperparam_pre_
UND
ER.xlsx'
)
as
writer
:
for
sheet_name
,
data
in
sheets_dict
.
items
():
for
sheet_name
,
data
in
sheets_dict
.
items
():
data
.
to_excel
(
writer
,
sheet_name
=
sheet_name
)
data
.
to_excel
(
writer
,
sheet_name
=
sheet_name
)
...
...
model_selection/output/hyperparam_pre_UNDER.xlsx
0 → 100644
View file @
c180f1dd
File added
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