yash-gupta-01 commited on
Commit
42ea9cb
·
verified ·
1 Parent(s): 4cf42b6

Update home.py

Browse files
Files changed (1) hide show
  1. home.py +190 -15
home.py CHANGED
@@ -1,6 +1,8 @@
1
  import streamlit as st
2
  from streamlit_lottie import st_lottie
3
  import requests
 
 
4
 
5
  # Function to load Lottie animation from a URL
6
  def load_lottieurl(url: str):
@@ -33,19 +35,11 @@ st.markdown("""
33
  --text-muted: #a3a3a3;
34
  }
35
  }
36
- body {
37
- margin: 0;
38
- padding: 0;
39
- font-family: 'Roboto', sans-serif;
40
- background-color: var(--background-color) !important;
41
- color: var(--text-color) !important;
42
- }
43
  h1 { font-size: 3rem; color: var(--primary-color) !important; text-align: center; margin-bottom: 15px; }
44
  h2, h3 { font-size: 1.5rem; color: var(--secondary-color) !important; text-align: center; margin-top: 20px; }
45
  p { font-family: 'Georgia', serif; color: var(--text-color) !important; line-height: 1.6; text-align: justify; }
46
- .about-author { background-color: var(--card-bg) !important; border-radius: 10px; padding: 25px;
47
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); margin: 20px auto; max-width: 700px; text-align: center;
48
- color: var(--text-color) !important; }
49
  .social-icons { display: flex; justify-content: center; gap: 20px; margin-top: 15px; }
50
  .social-icons a img { width: 40px; height: 40px; transition: transform 0.3s ease-in-out; }
51
  .social-icons a img:hover { transform: scale(1.2); }
@@ -55,7 +49,7 @@ st.markdown("""
55
  """, unsafe_allow_html=True)
56
 
57
  # Sidebar Navigation
58
- episodes = [
59
  "Foundation",
60
  "ML Project Lifecycle",
61
  "Core Algorithms",
@@ -65,11 +59,10 @@ episodes = [
65
  "Natural Language Processing (NLP)",
66
  "Deployment & Tools"
67
  ]
68
- chapter = st.sidebar.radio("Chapter", episodes)
69
 
70
- # Initialize page variables
71
  page = None
72
-
73
  if chapter == "Foundation":
74
  page = st.sidebar.radio("Page", ["Home", "Introduction to Data Science", "Machine Learning vs Deep Learning"])
75
  elif chapter == "ML Project Lifecycle":
@@ -102,8 +95,26 @@ elif chapter == "Natural Language Processing (NLP)":
102
  elif chapter == "Deployment & Tools":
103
  page = st.sidebar.radio("Page", ["Model Deployment", "Working with Excel/CSV", "SQL for Data Science"])
104
 
105
- # Content rendering based on selection
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  if page == "Home":
 
107
  st.title("Mastering Machine Learning: From Basics To Brilliance 🚀🤖")
108
  st.markdown("## Your Gateway To Become Master In Data Science")
109
  anim = load_lottieurl("https://lottie.host/a45f4739-ef78-4193-b3f9-2ea435a190d5/PsTVRgXekn.json")
@@ -142,7 +153,21 @@ if page == "Home":
142
  </div>
143
  <footer>Made with ❤️ by <strong>Yash Harish Gupta</strong> | © 2024</footer>
144
  """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  else:
 
146
  st.header(page or chapter)
147
  st.write("Content for this page will go here.")
148
 
@@ -162,6 +187,156 @@ else:
162
  # except requests.exceptions.RequestException:
163
  # return None
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  # # CSS Styling for light and dark modes with adaptive theme support
166
  # st.markdown("""
167
  # <style>
 
1
  import streamlit as st
2
  from streamlit_lottie import st_lottie
3
  import requests
4
+ import importlib.util
5
+ import os
6
 
7
  # Function to load Lottie animation from a URL
8
  def load_lottieurl(url: str):
 
35
  --text-muted: #a3a3a3;
36
  }
37
  }
38
+ body { margin: 0; padding: 0; font-family: 'Roboto', sans-serif; background-color: var(--background-color) !important; color: var(--text-color) !important; }
 
 
 
 
 
 
39
  h1 { font-size: 3rem; color: var(--primary-color) !important; text-align: center; margin-bottom: 15px; }
40
  h2, h3 { font-size: 1.5rem; color: var(--secondary-color) !important; text-align: center; margin-top: 20px; }
41
  p { font-family: 'Georgia', serif; color: var(--text-color) !important; line-height: 1.6; text-align: justify; }
42
+ .about-author { background-color: var(--card-bg) !important; border-radius: 10px; padding: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin: 20px auto; max-width: 700px; text-align: center; color: var(--text-color) !important; }
 
 
43
  .social-icons { display: flex; justify-content: center; gap: 20px; margin-top: 15px; }
44
  .social-icons a img { width: 40px; height: 40px; transition: transform 0.3s ease-in-out; }
45
  .social-icons a img:hover { transform: scale(1.2); }
 
49
  """, unsafe_allow_html=True)
50
 
51
  # Sidebar Navigation
52
+ chapters = [
53
  "Foundation",
54
  "ML Project Lifecycle",
55
  "Core Algorithms",
 
59
  "Natural Language Processing (NLP)",
60
  "Deployment & Tools"
61
  ]
62
+ chapter = st.sidebar.radio("Chapter", chapters)
63
 
64
+ # Nested page selection based on chapter
65
  page = None
 
66
  if chapter == "Foundation":
67
  page = st.sidebar.radio("Page", ["Home", "Introduction to Data Science", "Machine Learning vs Deep Learning"])
68
  elif chapter == "ML Project Lifecycle":
 
95
  elif chapter == "Deployment & Tools":
96
  page = st.sidebar.radio("Page", ["Model Deployment", "Working with Excel/CSV", "SQL for Data Science"])
97
 
98
+ # Map pages to external scripts
99
+ page_to_script = {
100
+ "Introduction to Data Science": "01_introduction.py",
101
+ "Machine Learning vs Deep Learning": "02_ml_vs_dl.py",
102
+ "Life Cycle of ML Project": "03_life_cycle_of_ml_project.py",
103
+ "Data Handling": "04_data.py"
104
+ }
105
+
106
+ # Helper to load and execute a module from path
107
+ def run_script(path, func_name=None, *args):
108
+ full_path = os.path.join(os.path.dirname(__file__), path)
109
+ spec = importlib.util.spec_from_file_location(path, full_path)
110
+ module = importlib.util.module_from_spec(spec)
111
+ spec.loader.exec_module(module)
112
+ if func_name:
113
+ getattr(module, func_name)(*args)
114
+
115
+ # Content rendering
116
  if page == "Home":
117
+ # existing Home content
118
  st.title("Mastering Machine Learning: From Basics To Brilliance 🚀🤖")
119
  st.markdown("## Your Gateway To Become Master In Data Science")
120
  anim = load_lottieurl("https://lottie.host/a45f4739-ef78-4193-b3f9-2ea435a190d5/PsTVRgXekn.json")
 
153
  </div>
154
  <footer>Made with ❤️ by <strong>Yash Harish Gupta</strong> | © 2024</footer>
155
  """, unsafe_allow_html=True)
156
+
157
+ elif page in page_to_script:
158
+ script = page_to_script[page]
159
+ # call appropriate function if needed
160
+ if page == "Introduction to Data Science":
161
+ run_script(script, "show_content", "Introduction")
162
+ elif page == "Machine Learning vs Deep Learning":
163
+ run_script(script) # top-level execution handles its own nav
164
+ elif page == "Life Cycle of ML Project":
165
+ run_script(script, "draw_lifecycle_diagram")
166
+ elif page == "Data Handling":
167
+ run_script(script, "main")
168
+
169
  else:
170
+ # default placeholder for other pages
171
  st.header(page or chapter)
172
  st.write("Content for this page will go here.")
173
 
 
187
  # except requests.exceptions.RequestException:
188
  # return None
189
 
190
+ # # CSS Styling for adaptive light/dark modes
191
+ # st.markdown("""
192
+ # <style>
193
+ # :root {
194
+ # --background-color: #f8f9fa;
195
+ # --text-color: #212529;
196
+ # --primary-color: #007acc;
197
+ # --secondary-color: #005b96;
198
+ # --card-bg: #ffffff;
199
+ # --text-muted: #6c757d;
200
+ # }
201
+ # @media (prefers-color-scheme: dark) {
202
+ # :root {
203
+ # --background-color: #0e1117;
204
+ # --text-color: #e5e5e5;
205
+ # --primary-color: #29b6f6;
206
+ # --secondary-color: #90caf9;
207
+ # --card-bg: #1f2937;
208
+ # --text-muted: #a3a3a3;
209
+ # }
210
+ # }
211
+ # body {
212
+ # margin: 0;
213
+ # padding: 0;
214
+ # font-family: 'Roboto', sans-serif;
215
+ # background-color: var(--background-color) !important;
216
+ # color: var(--text-color) !important;
217
+ # }
218
+ # h1 { font-size: 3rem; color: var(--primary-color) !important; text-align: center; margin-bottom: 15px; }
219
+ # h2, h3 { font-size: 1.5rem; color: var(--secondary-color) !important; text-align: center; margin-top: 20px; }
220
+ # p { font-family: 'Georgia', serif; color: var(--text-color) !important; line-height: 1.6; text-align: justify; }
221
+ # .about-author { background-color: var(--card-bg) !important; border-radius: 10px; padding: 25px;
222
+ # box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); margin: 20px auto; max-width: 700px; text-align: center;
223
+ # color: var(--text-color) !important; }
224
+ # .social-icons { display: flex; justify-content: center; gap: 20px; margin-top: 15px; }
225
+ # .social-icons a img { width: 40px; height: 40px; transition: transform 0.3s ease-in-out; }
226
+ # .social-icons a img:hover { transform: scale(1.2); }
227
+ # footer { margin-top: 50px; text-align: center; font-family: 'Georgia', serif; color: var(--text-muted) !important; }
228
+ # .css-1d391kg, .css-1d391kg * { background-color: var(--card-bg) !important; color: var(--text-color) !important; }
229
+ # </style>
230
+ # """, unsafe_allow_html=True)
231
+
232
+ # # Sidebar Navigation
233
+ # episodes = [
234
+ # "Foundation",
235
+ # "ML Project Lifecycle",
236
+ # "Core Algorithms",
237
+ # "Model Evaluation",
238
+ # "Data Handling",
239
+ # "Computer Vision Basics",
240
+ # "Natural Language Processing (NLP)",
241
+ # "Deployment & Tools"
242
+ # ]
243
+ # chapter = st.sidebar.radio("Chapter", episodes)
244
+
245
+ # # Initialize page variables
246
+ # page = None
247
+
248
+ # if chapter == "Foundation":
249
+ # page = st.sidebar.radio("Page", ["Home", "Introduction to Data Science", "Machine Learning vs Deep Learning"])
250
+ # elif chapter == "ML Project Lifecycle":
251
+ # section = st.sidebar.radio("Section", ["Life Cycle of ML Project"])
252
+ # if section:
253
+ # page = st.sidebar.radio("Subtopic", [
254
+ # "Problem Statement", "Data Collection", "Data Preprocessing",
255
+ # "Exploratory Data Analysis (EDA)", "Feature Engineering", "Model Selection",
256
+ # "Model Training", "Model Evaluation & Tuning", "Model Deployment", "Monitoring"
257
+ # ])
258
+ # elif chapter == "Core Algorithms":
259
+ # page = st.sidebar.radio("Page", [
260
+ # "Linear Regression", "Logistic Regression", "k-Nearest Neighbors (kNN)",
261
+ # "Decision Trees", "Support Vector Machines (SVM)", "Ensemble Techniques"
262
+ # ])
263
+ # elif chapter == "Model Evaluation":
264
+ # page = st.sidebar.radio("Page", ["Performance Metrics"])
265
+ # if page == "Performance Metrics":
266
+ # page = st.sidebar.radio("Metric", ["Accuracy, Precision, Recall", "Confusion Matrix", "ROC-AUC"])
267
+ # elif chapter == "Data Handling":
268
+ # page = st.sidebar.radio("Page", ["Data Types", "Data Cleaning", "Feature Engineering"])
269
+ # if page == "Data Types":
270
+ # page = st.sidebar.radio("Type", ["Structured Data (SQL, Excel)", "Semi-Structured Data (JSON, XML)", "Unstructured Data (Images, Text)"])
271
+ # elif chapter == "Computer Vision Basics":
272
+ # page = st.sidebar.radio("Page", ["Image Processing", "OpenCV Basics"])
273
+ # if page == "Image Processing":
274
+ # page = st.sidebar.radio("Topic", ["Color Spaces", "Image Augmentation", "Splitting/Merging Images"])
275
+ # elif chapter == "Natural Language Processing (NLP)":
276
+ # page = st.sidebar.radio("Page", ["NLP Introduction", "Text Preprocessing"])
277
+ # elif chapter == "Deployment & Tools":
278
+ # page = st.sidebar.radio("Page", ["Model Deployment", "Working with Excel/CSV", "SQL for Data Science"])
279
+
280
+ # # Content rendering based on selection
281
+ # if page == "Home":
282
+ # st.title("Mastering Machine Learning: From Basics To Brilliance 🚀🤖")
283
+ # st.markdown("## Your Gateway To Become Master In Data Science")
284
+ # anim = load_lottieurl("https://lottie.host/a45f4739-ef78-4193-b3f9-2ea435a190d5/PsTVRgXekn.json")
285
+ # if anim:
286
+ # st_lottie(anim, height=200)
287
+ # st.subheader("About This Application")
288
+ # st.markdown("""
289
+ # This platform serves as a **comprehensive guide to Machine Learning and Data Science**.
290
+ # From grasping the fundamentals to deploying models, it offers insights into the entire lifecycle:
291
+ # - **Problem Definition**: Understand context and objectives.
292
+ # - **Data Handling**: Collect, clean, explore.
293
+ # - **Model Development**: Build and optimize.
294
+ # - **Model Deployment**: Deliver and monitor solutions.
295
+ # """)
296
+ # st.subheader("What You'll Learn Here")
297
+ # st.markdown("""
298
+ # 1. **Roadmaps**: Navigate challenges step-by-step.
299
+ # 2. **Hands-on Projects**: Applied examples.
300
+ # 3. **Visualizations**: Intuitive graphs.
301
+ # 4. **Insights**: Lessons from experience.
302
+ # """)
303
+ # st.markdown("""
304
+ # <div class='about-author'>
305
+ # <h2>About the Author</h2>
306
+ # <p>Hello! I'm <strong>Yash Harish Gupta</strong>, an aspiring data scientist passionate about ML.</p>
307
+ # </div>
308
+ # """, unsafe_allow_html=True)
309
+ # st.markdown("""
310
+ # <div class='social-icons'>
311
+ # <a href='https://www.linkedin.com/in/yash-harish-gupta-71b011189/' target='_blank'>
312
+ # <img src='https://upload.wikimedia.org/wikipedia/commons/c/ca/LinkedIn_logo_initials.png' alt='LinkedIn'>
313
+ # </a>
314
+ # <a href='https://github.com/YashGupta018' target='_blank'>
315
+ # <img src='https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png' alt='GitHub'>
316
+ # </a>
317
+ # </div>
318
+ # <footer>Made with ❤️ by <strong>Yash Harish Gupta</strong> | © 2024</footer>
319
+ # """, unsafe_allow_html=True)
320
+ # else:
321
+ # st.header(page or chapter)
322
+ # st.write("Content for this page will go here.")
323
+
324
+ # ----------------------------------------------------------------------------------------------------------------------------------------------------------
325
+
326
+ # import streamlit as st
327
+ # from streamlit_lottie import st_lottie
328
+ # import requests
329
+
330
+ # # Function to load Lottie animation from a URL
331
+ # def load_lottieurl(url: str):
332
+ # """Fetch Lottie animation JSON from a URL."""
333
+ # try:
334
+ # response = requests.get(url)
335
+ # if response.status_code == 200:
336
+ # return response.json()
337
+ # except requests.exceptions.RequestException:
338
+ # return None
339
+
340
  # # CSS Styling for light and dark modes with adaptive theme support
341
  # st.markdown("""
342
  # <style>