suvradeepp commited on
Commit
e829bef
·
verified ·
1 Parent(s): a6aee28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -27
app.py CHANGED
@@ -1,33 +1,75 @@
1
- # app.py
2
  import streamlit as st
3
- import runpy
 
4
 
5
- # 1. Page config & title
6
- st.set_page_config(page_title="Machine Learning Models Visualization Hub")
7
- st.title("Machine Learning Models Visualization Tools")
8
 
9
- # 2. Map display names filenames
10
  APPS = {
11
- "Gradient Descent Visualization": "gd_sgd_app.py",
12
- "Decision Tree (step-by-step)": "decision_tree_steps.py",
13
- "Bagging Classifier Visualization": "bagging_classifier_viz.py",
14
- "Bagging Regressor Visualization": "bagging_regressor_viz.py",
15
- "Voting Classifier Visualization": "voting_classifier_viz.py",
16
- "Voting Regressor Visualization": "voting_regressor_viz.py",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
 
19
- # 3. Check for query‑param to run one of the apps
20
- params = st.experimental_get_query_params()
21
- selected = params.get("app", [None])[0]
22
-
23
- if selected in APPS.values():
24
- # Run the selected Streamlit app in this process
25
- runpy.run_path(selected, run_name="__main__")
26
- else:
27
- # 4. Otherwise show a grid of buttons
28
- cols = st.columns(2)
29
- for idx, (label, fname) in enumerate(APPS.items()):
30
- col = cols[idx % 2]
31
- if col.button(label, key=label):
32
- # set the query‑param and rerun
33
- st.experimental_set_query_params(app=fname)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.")