Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,8 +87,6 @@ def load_model_and_data():
|
|
| 87 |
|
| 88 |
return model, X, y
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
import streamlit as st
|
| 93 |
import pandas as pd
|
| 94 |
import numpy as np
|
|
@@ -96,7 +94,7 @@ import matplotlib.pyplot as plt
|
|
| 96 |
from sklearn.tree import plot_tree, export_text
|
| 97 |
import seaborn as sns
|
| 98 |
from sklearn.preprocessing import LabelEncoder
|
| 99 |
-
from dtreeviz
|
| 100 |
|
| 101 |
|
| 102 |
def app():
|
|
@@ -155,7 +153,7 @@ def app():
|
|
| 155 |
st.text(tree_text)
|
| 156 |
else:
|
| 157 |
# Création de la visualisation dtreeviz
|
| 158 |
-
viz = dtreeviz(
|
| 159 |
model,
|
| 160 |
X,
|
| 161 |
y,
|
|
@@ -165,9 +163,10 @@ def app():
|
|
| 165 |
max_depth=max_depth
|
| 166 |
)
|
| 167 |
|
| 168 |
-
#
|
| 169 |
-
|
| 170 |
-
|
|
|
|
| 171 |
|
| 172 |
# Analyse de cohortes
|
| 173 |
elif page == "Analyse de cohortes":
|
|
@@ -254,4 +253,4 @@ def app():
|
|
| 254 |
st.write(rule)
|
| 255 |
|
| 256 |
if __name__ == "__main__":
|
| 257 |
-
app()
|
|
|
|
| 87 |
|
| 88 |
return model, X, y
|
| 89 |
|
|
|
|
|
|
|
| 90 |
import streamlit as st
|
| 91 |
import pandas as pd
|
| 92 |
import numpy as np
|
|
|
|
| 94 |
from sklearn.tree import plot_tree, export_text
|
| 95 |
import seaborn as sns
|
| 96 |
from sklearn.preprocessing import LabelEncoder
|
| 97 |
+
from dtreeviz import trees
|
| 98 |
|
| 99 |
|
| 100 |
def app():
|
|
|
|
| 153 |
st.text(tree_text)
|
| 154 |
else:
|
| 155 |
# Création de la visualisation dtreeviz
|
| 156 |
+
viz = trees.dtreeviz(
|
| 157 |
model,
|
| 158 |
X,
|
| 159 |
y,
|
|
|
|
| 163 |
max_depth=max_depth
|
| 164 |
)
|
| 165 |
|
| 166 |
+
# Sauvegarde temporaire et affichage
|
| 167 |
+
st.set_option('deprecation.showPyplotGlobalUse', False)
|
| 168 |
+
fig = viz.view()
|
| 169 |
+
st.pyplot(fig)
|
| 170 |
|
| 171 |
# Analyse de cohortes
|
| 172 |
elif page == "Analyse de cohortes":
|
|
|
|
| 253 |
st.write(rule)
|
| 254 |
|
| 255 |
if __name__ == "__main__":
|
| 256 |
+
app()
|