Mpavan45 commited on
Commit
69de968
Β·
verified Β·
1 Parent(s): 75c0ea6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -33
app.py CHANGED
@@ -223,56 +223,51 @@ def neural_networks():
223
  '''
224
  return neural
225
 
 
226
  # Sidebar for content navigation
227
  st.sidebar.header("πŸ“š Contents")
228
 
229
- # Show Introduction first in the sidebar (Only display the Introduction option initially)
230
- intro_option = st.sidebar.radio("πŸ“š Introduction", ["Introduction", "Select a Topic"], index=0)
 
231
 
232
- # Grouping the types of machine learning into one section (Only after Introduction is selected)
233
- if intro_option == "Introduction":
234
  types_of_ml = st.sidebar.radio("πŸ“Š Types of Machine Learning",
235
  ["Supervised Learning", "Unsupervised Learning", "Reinforcement Learning"])
236
  else:
237
  types_of_ml = None
238
 
239
- # Grouping other topics under a separate section (Only after Introduction is selected)
240
- if intro_option == "Introduction":
241
  popular_algorithms = st.sidebar.radio("πŸš€ Popular Algorithms",
242
  ["Linear Regression", "Logistic Regression", "Decision Trees",
243
  "K-Nearest Neighbors (KNN)", "Support Vector Machines (SVM)", "Neural Networks"])
244
  else:
245
  popular_algorithms = None
246
 
247
- # Mapping page functions to selection
248
- pages = {
249
- "Supervised Learning": supervised_learning,
250
- "Unsupervised Learning": unsupervised_learning,
251
- "Reinforcement Learning": reinforcement_learning,
252
- "Linear Regression": linear_regression,
253
- "Logistic Regression": logistic_regression,
254
- "Decision Trees": decision_trees,
255
- "K-Nearest Neighbors (KNN)": knn,
256
- "Support Vector Machines (SVM)": svm,
257
- "Neural Networks": neural_networks
258
- }
259
-
260
  # Main content area
261
  st.markdown("<h1 style='text-align: center; color: orange;'>Machine Learning (ML)</h1>", unsafe_allow_html=True)
262
 
263
- # Show the Introduction content first (Only show if selected)
264
- if intro_option == "Introduction":
265
  st.markdown(introduction_to_ml())
266
 
267
- # Show content based on the selected type of machine learning or algorithm from the sidebar
268
- if types_of_ml:
269
- st.markdown(f"<h2 style='text-align: center; color: orange;'>{types_of_ml}</h2>", unsafe_allow_html=True)
270
- content_function = pages.get(types_of_ml, None)
271
- if content_function:
272
- st.markdown(content_function())
273
-
274
- if popular_algorithms:
275
- st.markdown(f"<h2 style='text-align: center; color: orange;'>{popular_algorithms}</h2>", unsafe_allow_html=True)
276
- content_function = pages.get(popular_algorithms, None)
277
- if content_function:
278
- st.markdown(content_function())
 
 
 
 
 
 
 
 
223
  '''
224
  return neural
225
 
226
+ # Sidebar for content navigation
227
  # Sidebar for content navigation
228
  st.sidebar.header("πŸ“š Contents")
229
 
230
+ # Show Introduction first in the sidebar
231
+ page = st.sidebar.radio("πŸ“š Select a Topic",
232
+ ["Introduction", "Types of Machine Learning", "Popular Algorithms"])
233
 
234
+ # Conditional options based on sidebar selection
235
+ if page == "Types of Machine Learning":
236
  types_of_ml = st.sidebar.radio("πŸ“Š Types of Machine Learning",
237
  ["Supervised Learning", "Unsupervised Learning", "Reinforcement Learning"])
238
  else:
239
  types_of_ml = None
240
 
241
+ if page == "Popular Algorithms":
 
242
  popular_algorithms = st.sidebar.radio("πŸš€ Popular Algorithms",
243
  ["Linear Regression", "Logistic Regression", "Decision Trees",
244
  "K-Nearest Neighbors (KNN)", "Support Vector Machines (SVM)", "Neural Networks"])
245
  else:
246
  popular_algorithms = None
247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  # Main content area
249
  st.markdown("<h1 style='text-align: center; color: orange;'>Machine Learning (ML)</h1>", unsafe_allow_html=True)
250
 
251
+ # Display content based on the selected page
252
+ if page == "Introduction":
253
  st.markdown(introduction_to_ml())
254
 
255
+ elif types_of_ml == "Supervised Learning":
256
+ st.markdown(supervised_learning())
257
+ elif types_of_ml == "Unsupervised Learning":
258
+ st.markdown(unsupervised_learning())
259
+ elif types_of_ml == "Reinforcement Learning":
260
+ st.markdown(reinforcement_learning())
261
+
262
+ elif popular_algorithms == "Linear Regression":
263
+ st.markdown(linear_regression())
264
+ elif popular_algorithms == "Logistic Regression":
265
+ st.markdown(logistic_regression())
266
+ elif popular_algorithms == "Decision Trees":
267
+ st.markdown(decision_trees())
268
+ elif popular_algorithms == "K-Nearest Neighbors (KNN)":
269
+ st.markdown(knn())
270
+ elif popular_algorithms == "Support Vector Machines (SVM)":
271
+ st.markdown(svm())
272
+ elif popular_algorithms == "Neural Networks":
273
+ st.markdown(neural_networks())