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
2d0dad71
Commit
2d0dad71
authored
Jun 17, 2024
by
Joaquin Torres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Summary interaction plots gen for OVER
parent
b7c120bf
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5292 additions
and
8 deletions
+5292
-8
explicability/output/plots/inters/post_OVER_XGB.svg
explicability/output/plots/inters/post_OVER_XGB.svg
+2670
-0
explicability/output/plots/inters/pre_OVER_XGB.svg
explicability/output/plots/inters/pre_OVER_XGB.svg
+2606
-0
explicability/shap_plots.py
explicability/shap_plots.py
+16
-8
No files found.
explicability/output/plots/inters/post_OVER_XGB.svg
0 → 100644
View file @
2d0dad71
This diff is collapsed.
Click to expand it.
explicability/output/plots/inters/pre_OVER_XGB.svg
0 → 100644
View file @
2d0dad71
This diff is collapsed.
Click to expand it.
explicability/shap_plots.py
View file @
2d0dad71
...
...
@@ -3,6 +3,7 @@
import
pandas
as
pd
import
numpy
as
np
import
shap
import
matplotlib.pyplot
as
plt
# --------------------------------------------------------------------------------------------------------
# Reading test data
...
...
@@ -37,18 +38,25 @@ if __name__ == "__main__":
2
:
"OVER"
,
3
:
"UNDER"
}
model_choices
=
{
"ORIG"
:
"XGB"
,
"ORIG_CW"
:
"RF"
,
"OVER"
:
"XGB"
,
"UNDER"
:
"XGB"
}
# --------------------------------------------------------------------------------------------------------
# Plot generation
# --------------------------------------------------------------------------------------------------------
for
i
,
group
in
enumerate
([
'pre'
,
'post'
]):
# Get test dataset based on group, add column names
X_test
=
data_dic
[
'X_test_'
+
group
]
y_test
=
data_dic
[
'y_test_'
+
group
]
for
j
,
method
in
enumerate
([
''
,
''
,
'over_'
,
'under_'
]):
for
j
,
method
in
enumerate
([
''
,
''
,
'over_'
,
'under_'
]):
if
method
!=
'over_'
:
continue
for
i
,
group
in
enumerate
([
'pre'
,
'post'
]):
X_test
=
data_dic
[
'X_test_'
+
group
]
y_test
=
data_dic
[
'y_test_'
+
group
]
print
(
f
"{group}-{method_names[j]}"
)
method_name
=
method_names
[
j
]
shap_vals
=
np
.
load
(
f
'./output/shap_values/{group}_{method_name}.npy'
)
# print(f'Loaded SHAP values. Shape: {shap_vals.shape}')
model_name
=
model_choices
[
method_name
]
shap_inter_vals
=
np
.
load
(
f
'./output/shap_inter_values/{group}_{method_name}.npy'
)
# print(f'Loaded SHAP INTER values. Shape: {shap_inter_vals.shape}')
shap
.
summary_plot
(
shap_inter_vals
,
X_test
,
max_display
=
15
)
plt
.
savefig
(
f
'./output/plots/inters/{group}_{method_name}_{model_name}.svg'
,
format
=
'svg'
,
dpi
=
1250
)
\ No newline at end of file
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