import streamlit as st
# ---------- Page Config ----------
st.set_page_config(
page_title="📘 Machine Learning Notes Hub",
layout="wide",
initial_sidebar_state="expanded"
)
# ---------- Custom CSS ----------
st.markdown("""
""", unsafe_allow_html=True)
# ---------- Sidebar Navigation ----------
st.sidebar.title("📚 ML Notebook")
page = st.sidebar.radio("Go to", [
"Home",
"Supervised Learning",
"Unsupervised Learning",
"Evaluation Metrics",
"Data Preprocessing",
"Interview Tips",
"Resources"
])
# ---------- Home Page ----------
if page == "Home":
st.markdown('
📘 Machine Learning Notes
', unsafe_allow_html=True)
st.markdown('Your personal guide to mastering ML concepts!
', unsafe_allow_html=True)
st.markdown("### 🚀 Why Use This App?")
st.markdown("""
- Concise, organized ML notes
- Beginner-friendly explanations with examples
- Great for revision, projects, and interviews
""")
st.markdown('', unsafe_allow_html=True)
st.markdown("### 📌 Topics Covered:")
st.markdown("""
- 🔹 Supervised Learning
- 🔹 Unsupervised Learning
- 🔹 Model Evaluation Metrics
- 🔹 Data Preprocessing
- 🔹 Interview Tips
- 🔹 Useful Resources
""")
st.markdown('
', unsafe_allow_html=True)
st.info("🛠 More features coming soon: interactive examples, quizzes, and visual diagrams!")
# ---------- Supervised Learning ----------
elif page == "Supervised Learning":
st.title("🔍 Supervised Learning")
st.write("""
Supervised Learning is a type of machine learning where the model learns from labeled data
— meaning the input comes with the correct output.
""")
with st.expander("📘 Key Concepts"):
st.markdown("""
- **Goal:** Predict an output based on given input.
- **Types:**
- **Regression:** Predicts continuous values (e.g., house price prediction)
- **Classification:** Predicts categories (e.g., spam or not spam)
- **Examples:**
- Predicting a student's exam score based on study hours (Regression)
- Classifying emails as spam or not spam (Classification)
""")
with st.expander("💡 Real-life Analogy"):
st.write("""
Imagine you are teaching a child to recognize fruits.
You show an apple and say, "This is an apple."
You show a banana and say, "This is a banana."
After many examples, the child can identify fruits on their own.
""")
# ---------- Unsupervised Learning ----------
elif page == "Unsupervised Learning":
st.title("🧩 Unsupervised Learning")
st.write("""
Unsupervised Learning works with **unlabeled data** — meaning we only have inputs and no corresponding outputs.
The algorithm tries to find patterns or groupings in the data.
""")
with st.expander("📘 Key Concepts"):
st.markdown("""
- **Goal:** Discover hidden structure in data.
- **Types:**
- **Clustering:** Grouping similar items together (e.g., customer segmentation)
- **Dimensionality Reduction:** Reducing features while keeping important info (e.g., PCA)
- **Examples:**
- Grouping customers by purchasing behavior
- Compressing images while keeping quality
""")
with st.expander("💡 Real-life Analogy"):
st.write("""
Think of visiting a supermarket where items are grouped by similarity:
fruits in one section, vegetables in another.
Nobody told the store which items belong together — they just grouped them by observation.
""")
# ---------- Evaluation Metrics ----------
elif page == "Evaluation Metrics":
st.title("📏 Model Evaluation Metrics")
st.write("Evaluation metrics tell us how well our machine learning model is performing.")
with st.expander("📊 For Classification"):
st.markdown("""
- **Accuracy** = Correct predictions / Total predictions
- **Precision** = Of all predicted positives, how many are actually positive?
- **Recall** = Of all actual positives, how many did we find?
- **F1-Score** = Harmonic mean of precision & recall
- **Confusion Matrix** = Table showing TP, FP, TN, FN
""")
with st.expander("📈 For Regression"):
st.markdown("""
- **MAE (Mean Absolute Error)** = Average absolute difference between predictions and actual values
- **MSE (Mean Squared Error)** = Average of squared differences
- **RMSE** = Square root of MSE
- **R² Score** = Proportion of variance explained by the model
""")
# ---------- Data Preprocessing ----------
elif page == "Data Preprocessing":
st.title("⚙ Data Preprocessing")
st.write("""
Preprocessing prepares raw data so that a machine learning model can use it effectively.
""")
with st.expander("📘 Steps"):
st.markdown("""
1. **Handling Missing Values** — Remove or fill in missing data
2. **Encoding Categorical Data** — Convert text labels to numbers
3. **Feature Scaling** — Normalize or standardize values
4. **Removing Outliers** — Detect and handle extreme values
""")
# ---------- Interview Tips ----------
elif page == "Interview Tips":
st.title("💼 ML Interview Tips")
st.markdown("""
- Be clear with definitions and examples
- Explain algorithms with analogies
- Understand trade-offs between models
- Practice with real datasets
""")
# ---------- Resources ----------
elif page == "Resources":
st.title("📚 Useful Resources")
st.markdown("""
- [Scikit-learn Docs](https://scikit-learn.org/)
- [Kaggle Courses](https://www.kaggle.com/learn)
- [Google ML Crash Course](https://developers.google.com/machine-learning/crash-course)
""")