Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from visualize import plotSurface
|
| 3 |
+
from DecisionTree import predictor
|
| 4 |
+
|
| 5 |
+
def md_contents():
|
| 6 |
+
collapse_content = """
|
| 7 |
+
<details>
|
| 8 |
+
<summary>Getting started</summary>
|
| 9 |
+
<a href="https://mp.weixin.qq.com/s/OFoTbEcvbe-k3Ys-wTStPA">streamlit 极简入门</a>
|
| 10 |
+
</details>
|
| 11 |
+
|
| 12 |
+
<details>
|
| 13 |
+
<summary>Additional knowledge</summary>
|
| 14 |
+
<a href="https://mp.weixin.qq.com/s/74ehblIzwe4rmCM6K-ynEA">决策树的可视化</a>
|
| 15 |
+
|
| 16 |
+
</details>
|
| 17 |
+
|
| 18 |
+
"""
|
| 19 |
+
st.title("决策树西瓜挑选器")
|
| 20 |
+
st.markdown(collapse_content, unsafe_allow_html=True)
|
| 21 |
+
|
| 22 |
+
def body():
|
| 23 |
+
predictor()
|
| 24 |
+
st.markdown("---")
|
| 25 |
+
st.write("Source Code")
|
| 26 |
+
with st.expander("data.py", expanded=False):
|
| 27 |
+
with open("data.py", encoding="UTF-8") as f:
|
| 28 |
+
st.code(f.read(), language="python")
|
| 29 |
+
|
| 30 |
+
with st.expander("DecisionTree.py", expanded=False):
|
| 31 |
+
with open("DecisionTree.py", encoding="UTF-8") as f:
|
| 32 |
+
st.code(f.read(), language="python")
|
| 33 |
+
|
| 34 |
+
with st.expander("visualize.py", expanded=False):
|
| 35 |
+
with open("visualize.py", encoding="UTF-8") as f:
|
| 36 |
+
st.code(f.read(), language="python")
|
| 37 |
+
|
| 38 |
+
if st.checkbox("decisionTreeViz"):
|
| 39 |
+
# viz = decisionTreeViz(model)
|
| 40 |
+
# svg = viz.svg()
|
| 41 |
+
# svg_write(svg)
|
| 42 |
+
ps=plotSurface()
|
| 43 |
+
|
| 44 |
+
if __name__ == '__main__':
|
| 45 |
+
md_contents()
|
| 46 |
+
body()
|