Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,75 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import streamlit as st
|
| 3 |
-
import
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
st.
|
| 7 |
-
st.title("Machine Learning Models Visualization Tools")
|
| 8 |
|
| 9 |
-
#
|
| 10 |
APPS = {
|
| 11 |
-
"
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
"Voting
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import subprocess
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
st.set_page_config(page_title="ML Visualizations Launcher", layout="wide")
|
| 6 |
+
st.title("Machine Learning Visualizations Dashboard")
|
|
|
|
| 7 |
|
| 8 |
+
# List of available apps with display names and ports
|
| 9 |
APPS = {
|
| 10 |
+
"Decision Tree Steps": {
|
| 11 |
+
"file": "decision_tree_steps.py",
|
| 12 |
+
"port": 8502
|
| 13 |
+
},
|
| 14 |
+
"Voting Regressor": {
|
| 15 |
+
"file": "voting_regressor_viz.py",
|
| 16 |
+
"port": 8503
|
| 17 |
+
},
|
| 18 |
+
"Voting Classifier": {
|
| 19 |
+
"file": "voting_classifier_viz.py",
|
| 20 |
+
"port": 8504
|
| 21 |
+
},
|
| 22 |
+
"Bagging Regressor": {
|
| 23 |
+
"file": "bagging_regressor_viz.py",
|
| 24 |
+
"port": 8505
|
| 25 |
+
},
|
| 26 |
+
"Bagging Classifier": {
|
| 27 |
+
"file": "bagging_classifier_viz.py",
|
| 28 |
+
"port": 8506
|
| 29 |
+
},
|
| 30 |
+
"GD/SGD Visualizer": {
|
| 31 |
+
"file": "gd_sgd_app.py",
|
| 32 |
+
"port": 8507
|
| 33 |
+
}
|
| 34 |
}
|
| 35 |
|
| 36 |
+
def launch_app(file_path, port):
|
| 37 |
+
"""Launch a Streamlit app in a subprocess"""
|
| 38 |
+
cmd = f"streamlit run {file_path} --server.port {port}"
|
| 39 |
+
subprocess.Popen(cmd, shell=True)
|
| 40 |
+
|
| 41 |
+
# Create columns for app launcher buttons
|
| 42 |
+
col1, col2, col3 = st.columns(3)
|
| 43 |
+
|
| 44 |
+
with col1:
|
| 45 |
+
for app_name in list(APPS.keys())[::3]:
|
| 46 |
+
app = APPS[app_name]
|
| 47 |
+
if os.path.exists(app["file"]):
|
| 48 |
+
if st.button(f"🚀 {app_name}"):
|
| 49 |
+
launch_app(app["file"], app["port"])
|
| 50 |
+
st.toast(f"Opening {app_name} on port {app['port']}", icon="✅")
|
| 51 |
+
else:
|
| 52 |
+
st.error(f"Missing file: {app['file']}")
|
| 53 |
+
|
| 54 |
+
with col2:
|
| 55 |
+
for app_name in list(APPS.keys())[1::3]:
|
| 56 |
+
app = APPS[app_name]
|
| 57 |
+
if os.path.exists(app["file"]):
|
| 58 |
+
if st.button(f"🚀 {app_name}"):
|
| 59 |
+
launch_app(app["file"], app["port"])
|
| 60 |
+
st.toast(f"Opening {app_name} on port {app['port']}", icon="✅")
|
| 61 |
+
else:
|
| 62 |
+
st.error(f"Missing file: {app['file']}")
|
| 63 |
+
|
| 64 |
+
with col3:
|
| 65 |
+
for app_name in list(APPS.keys())[2::3]:
|
| 66 |
+
app = APPS[app_name]
|
| 67 |
+
if os.path.exists(app["file"]):
|
| 68 |
+
if st.button(f"🚀 {app_name}"):
|
| 69 |
+
launch_app(app["file"], app["port"])
|
| 70 |
+
st.toast(f"Opening {app_name} on port {app['port']}", icon="✅")
|
| 71 |
+
else:
|
| 72 |
+
st.error(f"Missing file: {app['file']}")
|
| 73 |
+
|
| 74 |
+
st.markdown("---")
|
| 75 |
+
st.info("ℹ️ Each app will open in a new tab automatically. Allow pop-ups if your browser blocks them.")
|