Spaces:
Build error
Build error
LethallyHealthy
commited on
Commit
·
a428eda
1
Parent(s):
2b1d5a0
Update predictor.py
Browse files- predictor.py +8 -5
predictor.py
CHANGED
@@ -4,6 +4,7 @@ import numpy as np
|
|
4 |
import lightgbm as lgb
|
5 |
from lightgbm.callback import early_stopping
|
6 |
import shap
|
|
|
7 |
|
8 |
from sklearn.ensemble import GradientBoostingRegressor
|
9 |
from sklearn.model_selection import train_test_split
|
@@ -119,14 +120,16 @@ def create_shap_models(data):
|
|
119 |
obj1 = shap.force_plot(explainer.expected_value, shap_values=shap_values, feature_names=data.columns)
|
120 |
|
121 |
shap.initjs()
|
122 |
-
|
|
|
123 |
|
124 |
shap.initjs()
|
125 |
-
|
|
|
126 |
|
127 |
interaction_values = explainer.shap_interaction_values(data)
|
128 |
interaction_values[0].round(2)
|
129 |
-
pd.DataFrame(interaction_values[0].round(2)).head(60)
|
130 |
|
131 |
-
|
132 |
-
return
|
|
|
4 |
import lightgbm as lgb
|
5 |
from lightgbm.callback import early_stopping
|
6 |
import shap
|
7 |
+
import streamlit as st
|
8 |
|
9 |
from sklearn.ensemble import GradientBoostingRegressor
|
10 |
from sklearn.model_selection import train_test_split
|
|
|
120 |
obj1 = shap.force_plot(explainer.expected_value, shap_values=shap_values, feature_names=data.columns)
|
121 |
|
122 |
shap.initjs()
|
123 |
+
shap.decision_plot(explainer.expected_value, shap_values, feature_names=np.array(data.columns))
|
124 |
+
st.pyplot(bbox_inches='tight')
|
125 |
|
126 |
shap.initjs()
|
127 |
+
shap.summary_plot(shap_values=shap_values, feature_names=data.columns)
|
128 |
+
st.pyplot(bbox_inches='tight')
|
129 |
|
130 |
interaction_values = explainer.shap_interaction_values(data)
|
131 |
interaction_values[0].round(2)
|
132 |
+
st.write(pd.DataFrame(interaction_values[0].round(2)).head(60))
|
133 |
|
134 |
+
|
135 |
+
return obj1
|