Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ def generate_ml_blog():
|
|
| 13 |
def introduction_to_ml():
|
| 14 |
introduction_blog = '''
|
| 15 |
## Introduction to Machine Learning (ML)
|
| 16 |
-
|
| 17 |
|
| 18 |
### Types of Machine Learning
|
| 19 |
There are three main types of machine learning:
|
|
@@ -226,64 +226,24 @@ def neural_networks():
|
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
-
import streamlit as st
|
| 230 |
-
|
| 231 |
-
# Define page functions (Make sure these functions are defined elsewhere in your code)
|
| 232 |
-
def introduction_to_ml():
|
| 233 |
-
st.title("Introduction to Machine Learning (ML)")
|
| 234 |
-
# Add content for the Introduction page
|
| 235 |
-
|
| 236 |
-
def supervised_learning():
|
| 237 |
-
st.title("Supervised Learning")
|
| 238 |
-
# Add content for Supervised Learning
|
| 239 |
-
|
| 240 |
-
def unsupervised_learning():
|
| 241 |
-
st.title("Unsupervised Learning")
|
| 242 |
-
# Add content for Unsupervised Learning
|
| 243 |
-
|
| 244 |
-
def reinforcement_learning():
|
| 245 |
-
st.title("Reinforcement Learning")
|
| 246 |
-
# Add content for Reinforcement Learning
|
| 247 |
-
|
| 248 |
-
def linear_regression():
|
| 249 |
-
st.title("Linear Regression")
|
| 250 |
-
# Add content for Linear Regression
|
| 251 |
-
|
| 252 |
-
def logistic_regression():
|
| 253 |
-
st.title("Logistic Regression")
|
| 254 |
-
# Add content for Logistic Regression
|
| 255 |
-
|
| 256 |
-
def decision_trees():
|
| 257 |
-
st.title("Decision Trees")
|
| 258 |
-
# Add content for Decision Trees
|
| 259 |
-
|
| 260 |
-
def knn():
|
| 261 |
-
st.title("K-Nearest Neighbors (KNN)")
|
| 262 |
-
# Add content for K-Nearest Neighbors
|
| 263 |
-
|
| 264 |
-
def svm():
|
| 265 |
-
st.title("Support Vector Machines (SVM)")
|
| 266 |
-
# Add content for SVM
|
| 267 |
-
|
| 268 |
-
def neural_networks():
|
| 269 |
-
st.title("Neural Networks")
|
| 270 |
-
# Add content for Neural Networks
|
| 271 |
|
| 272 |
# Sidebar for content navigation
|
| 273 |
st.sidebar.header("π Contents")
|
| 274 |
|
|
|
|
|
|
|
|
|
|
| 275 |
# Grouping the types of machine learning into one section
|
| 276 |
types_of_ml = st.sidebar.radio("π Types of Machine Learning",
|
| 277 |
-
["Supervised Learning", "Unsupervised Learning", "Reinforcement Learning"])
|
| 278 |
|
| 279 |
# Grouping other topics under a separate section
|
| 280 |
popular_algorithms = st.sidebar.radio("π Popular Algorithms",
|
| 281 |
-
["Linear Regression", "Logistic Regression", "Decision Trees",
|
| 282 |
"K-Nearest Neighbors (KNN)", "Support Vector Machines (SVM)", "Neural Networks"])
|
| 283 |
|
| 284 |
# Mapping page functions to selection
|
| 285 |
pages = {
|
| 286 |
-
"Introduction": introduction_to_ml,
|
| 287 |
"Supervised Learning": supervised_learning,
|
| 288 |
"Unsupervised Learning": unsupervised_learning,
|
| 289 |
"Reinforcement Learning": reinforcement_learning,
|
|
@@ -297,26 +257,20 @@ pages = {
|
|
| 297 |
|
| 298 |
# Main content area
|
| 299 |
st.markdown("<h1 style='text-align: center; color: orange;'>Machine Learning (ML)</h1>", unsafe_allow_html=True)
|
| 300 |
-
st.markdown(generate_ml_blog())
|
| 301 |
-
|
| 302 |
-
# Use the selected type of machine learning or algorithm to show the content
|
| 303 |
-
if types_of_ml in pages:
|
| 304 |
-
pages[types_of_ml]()
|
| 305 |
-
|
| 306 |
-
if popular_algorithms in pages:
|
| 307 |
-
pages[popular_algorithms]()
|
| 308 |
-
|
| 309 |
-
# Display the page content based on the selected page
|
| 310 |
-
st.markdown(f"<h2 style='text-align: center; color: orange;'>{types_of_ml}</h2>", unsafe_allow_html=True)
|
| 311 |
-
content_function = pages[types_of_ml] # Get the corresponding function
|
| 312 |
-
st.markdown(content_function())
|
| 313 |
-
|
| 314 |
-
# Alternatively, display the popular algorithms' content as well
|
| 315 |
-
st.markdown(f"<h2 style='text-align: center; color: orange;'>{popular_algorithms}</h2>", unsafe_allow_html=True)
|
| 316 |
-
content_function = pages[popular_algorithms] # Get the corresponding function
|
| 317 |
-
st.markdown(content_function())
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def introduction_to_ml():
|
| 14 |
introduction_blog = '''
|
| 15 |
## Introduction to Machine Learning (ML)
|
| 16 |
+
π€Machine Learning (ML) is a subset of Artificial Intelligence (AI) that enables computers to learn from data and make predictions or decisions without being explicitly programmed. It has revolutionized many industries and plays a crucial role in technologies such as self-driving cars, recommendation systems, and facial recognition.
|
| 17 |
|
| 18 |
### Types of Machine Learning
|
| 19 |
There are three main types of machine learning:
|
|
|
|
| 226 |
|
| 227 |
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
# Sidebar for content navigation
|
| 231 |
st.sidebar.header("π Contents")
|
| 232 |
|
| 233 |
+
# Show Introduction first in the sidebar
|
| 234 |
+
intro_option = st.sidebar.radio(["Introduction"])
|
| 235 |
+
|
| 236 |
# Grouping the types of machine learning into one section
|
| 237 |
types_of_ml = st.sidebar.radio("π Types of Machine Learning",
|
| 238 |
+
["Select a Type", "Supervised Learning", "Unsupervised Learning", "Reinforcement Learning"])
|
| 239 |
|
| 240 |
# Grouping other topics under a separate section
|
| 241 |
popular_algorithms = st.sidebar.radio("π Popular Algorithms",
|
| 242 |
+
["Select an Algorithm", "Linear Regression", "Logistic Regression", "Decision Trees",
|
| 243 |
"K-Nearest Neighbors (KNN)", "Support Vector Machines (SVM)", "Neural Networks"])
|
| 244 |
|
| 245 |
# Mapping page functions to selection
|
| 246 |
pages = {
|
|
|
|
| 247 |
"Supervised Learning": supervised_learning,
|
| 248 |
"Unsupervised Learning": unsupervised_learning,
|
| 249 |
"Reinforcement Learning": reinforcement_learning,
|
|
|
|
| 257 |
|
| 258 |
# Main content area
|
| 259 |
st.markdown("<h1 style='text-align: center; color: orange;'>Machine Learning (ML)</h1>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
+
# Show the Introduction content first
|
| 262 |
+
if intro_option == "Introduction":
|
| 263 |
+
st.markdown(introduction_to_ml())
|
| 264 |
+
|
| 265 |
+
# Show content based on the selected type of machine learning or algorithm from the sidebar
|
| 266 |
+
if types_of_ml != "Select a Type":
|
| 267 |
+
st.markdown(f"<h2 style='text-align: center; color: orange;'>{types_of_ml}</h2>", unsafe_allow_html=True)
|
| 268 |
+
content_function = pages.get(types_of_ml, None)
|
| 269 |
+
if content_function:
|
| 270 |
+
st.markdown(content_function())
|
| 271 |
+
|
| 272 |
+
if popular_algorithms != "Select an Algorithm":
|
| 273 |
+
st.markdown(f"<h2 style='text-align: center; color: orange;'>{popular_algorithms}</h2>", unsafe_allow_html=True)
|
| 274 |
+
content_function = pages.get(popular_algorithms, None)
|
| 275 |
+
if content_function:
|
| 276 |
+
st.markdown(content_function())
|