Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
-
# Page
|
| 4 |
st.set_page_config(
|
| 5 |
-
page_title="π
|
| 6 |
layout="wide",
|
| 7 |
initial_sidebar_state="expanded"
|
| 8 |
)
|
| 9 |
|
| 10 |
-
#
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
| 13 |
.main-title {
|
|
@@ -19,13 +19,13 @@ st.markdown("""
|
|
| 19 |
}
|
| 20 |
.subtitle {
|
| 21 |
font-size: 1.2rem;
|
| 22 |
-
color: #
|
| 23 |
text-align: center;
|
| 24 |
margin-bottom: 2rem;
|
| 25 |
}
|
| 26 |
.note-box {
|
| 27 |
background-color: #f9f9f9;
|
| 28 |
-
padding:
|
| 29 |
border-radius: 10px;
|
| 30 |
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
| 31 |
margin-bottom: 1rem;
|
|
@@ -33,11 +33,19 @@ st.markdown("""
|
|
| 33 |
</style>
|
| 34 |
""", unsafe_allow_html=True)
|
| 35 |
|
| 36 |
-
#
|
| 37 |
st.sidebar.title("π ML Notebook")
|
| 38 |
-
page = st.sidebar.radio("Go to", [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
#
|
| 41 |
if page == "Home":
|
| 42 |
st.markdown('<div class="main-title">π Machine Learning Notes</div>', unsafe_allow_html=True)
|
| 43 |
st.markdown('<div class="subtitle">Your personal guide to mastering ML concepts!</div>', unsafe_allow_html=True)
|
|
@@ -45,8 +53,7 @@ if page == "Home":
|
|
| 45 |
st.markdown("### π Why Use This App?")
|
| 46 |
st.markdown("""
|
| 47 |
- Concise, organized ML notes
|
| 48 |
-
-
|
| 49 |
-
- Interactive widgets (coming soon)
|
| 50 |
- Great for revision, projects, and interviews
|
| 51 |
""")
|
| 52 |
|
|
@@ -57,31 +64,118 @@ if page == "Home":
|
|
| 57 |
- πΉ Unsupervised Learning
|
| 58 |
- πΉ Model Evaluation Metrics
|
| 59 |
- πΉ Data Preprocessing
|
| 60 |
-
- πΉ Tips
|
| 61 |
- πΉ Useful Resources
|
| 62 |
""")
|
| 63 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 64 |
|
| 65 |
-
st.
|
| 66 |
|
| 67 |
-
#
|
| 68 |
elif page == "Supervised Learning":
|
| 69 |
st.title("π Supervised Learning")
|
| 70 |
-
st.write("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
elif page == "Unsupervised Learning":
|
| 73 |
st.title("π§© Unsupervised Learning")
|
| 74 |
-
st.write("
|
|
|
|
|
|
|
|
|
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
elif page == "Evaluation Metrics":
|
| 77 |
st.title("π Model Evaluation Metrics")
|
| 78 |
-
st.write("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
elif page == "Resources":
|
| 81 |
-
st.title("π Resources")
|
| 82 |
st.markdown("""
|
| 83 |
- [Scikit-learn Docs](https://scikit-learn.org/)
|
| 84 |
- [Kaggle Courses](https://www.kaggle.com/learn)
|
| 85 |
- [Google ML Crash Course](https://developers.google.com/machine-learning/crash-course)
|
| 86 |
""")
|
| 87 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
+
# ---------- Page Config ----------
|
| 4 |
st.set_page_config(
|
| 5 |
+
page_title="π Machine Learning Notes Hub",
|
| 6 |
layout="wide",
|
| 7 |
initial_sidebar_state="expanded"
|
| 8 |
)
|
| 9 |
|
| 10 |
+
# ---------- Custom CSS ----------
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
| 13 |
.main-title {
|
|
|
|
| 19 |
}
|
| 20 |
.subtitle {
|
| 21 |
font-size: 1.2rem;
|
| 22 |
+
color: #555;
|
| 23 |
text-align: center;
|
| 24 |
margin-bottom: 2rem;
|
| 25 |
}
|
| 26 |
.note-box {
|
| 27 |
background-color: #f9f9f9;
|
| 28 |
+
padding: 1rem;
|
| 29 |
border-radius: 10px;
|
| 30 |
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
| 31 |
margin-bottom: 1rem;
|
|
|
|
| 33 |
</style>
|
| 34 |
""", unsafe_allow_html=True)
|
| 35 |
|
| 36 |
+
# ---------- Sidebar Navigation ----------
|
| 37 |
st.sidebar.title("π ML Notebook")
|
| 38 |
+
page = st.sidebar.radio("Go to", [
|
| 39 |
+
"Home",
|
| 40 |
+
"Supervised Learning",
|
| 41 |
+
"Unsupervised Learning",
|
| 42 |
+
"Evaluation Metrics",
|
| 43 |
+
"Data Preprocessing",
|
| 44 |
+
"Interview Tips",
|
| 45 |
+
"Resources"
|
| 46 |
+
])
|
| 47 |
|
| 48 |
+
# ---------- Home Page ----------
|
| 49 |
if page == "Home":
|
| 50 |
st.markdown('<div class="main-title">π Machine Learning Notes</div>', unsafe_allow_html=True)
|
| 51 |
st.markdown('<div class="subtitle">Your personal guide to mastering ML concepts!</div>', unsafe_allow_html=True)
|
|
|
|
| 53 |
st.markdown("### π Why Use This App?")
|
| 54 |
st.markdown("""
|
| 55 |
- Concise, organized ML notes
|
| 56 |
+
- Beginner-friendly explanations with examples
|
|
|
|
| 57 |
- Great for revision, projects, and interviews
|
| 58 |
""")
|
| 59 |
|
|
|
|
| 64 |
- πΉ Unsupervised Learning
|
| 65 |
- πΉ Model Evaluation Metrics
|
| 66 |
- πΉ Data Preprocessing
|
| 67 |
+
- πΉ Interview Tips
|
| 68 |
- πΉ Useful Resources
|
| 69 |
""")
|
| 70 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 71 |
|
| 72 |
+
st.info("π More features coming soon: interactive examples, quizzes, and visual diagrams!")
|
| 73 |
|
| 74 |
+
# ---------- Supervised Learning ----------
|
| 75 |
elif page == "Supervised Learning":
|
| 76 |
st.title("π Supervised Learning")
|
| 77 |
+
st.write("""
|
| 78 |
+
Supervised Learning is a type of machine learning where the model learns from labeled data
|
| 79 |
+
β meaning the input comes with the correct output.
|
| 80 |
+
""")
|
| 81 |
+
|
| 82 |
+
with st.expander("π Key Concepts"):
|
| 83 |
+
st.markdown("""
|
| 84 |
+
- **Goal:** Predict an output based on given input.
|
| 85 |
+
- **Types:**
|
| 86 |
+
- **Regression:** Predicts continuous values (e.g., house price prediction)
|
| 87 |
+
- **Classification:** Predicts categories (e.g., spam or not spam)
|
| 88 |
+
- **Examples:**
|
| 89 |
+
- Predicting a student's exam score based on study hours (Regression)
|
| 90 |
+
- Classifying emails as spam or not spam (Classification)
|
| 91 |
+
""")
|
| 92 |
|
| 93 |
+
with st.expander("π‘ Real-life Analogy"):
|
| 94 |
+
st.write("""
|
| 95 |
+
Imagine you are teaching a child to recognize fruits.
|
| 96 |
+
You show an apple and say, "This is an apple."
|
| 97 |
+
You show a banana and say, "This is a banana."
|
| 98 |
+
After many examples, the child can identify fruits on their own.
|
| 99 |
+
""")
|
| 100 |
+
|
| 101 |
+
# ---------- Unsupervised Learning ----------
|
| 102 |
elif page == "Unsupervised Learning":
|
| 103 |
st.title("π§© Unsupervised Learning")
|
| 104 |
+
st.write("""
|
| 105 |
+
Unsupervised Learning works with **unlabeled data** β meaning we only have inputs and no corresponding outputs.
|
| 106 |
+
The algorithm tries to find patterns or groupings in the data.
|
| 107 |
+
""")
|
| 108 |
|
| 109 |
+
with st.expander("π Key Concepts"):
|
| 110 |
+
st.markdown("""
|
| 111 |
+
- **Goal:** Discover hidden structure in data.
|
| 112 |
+
- **Types:**
|
| 113 |
+
- **Clustering:** Grouping similar items together (e.g., customer segmentation)
|
| 114 |
+
- **Dimensionality Reduction:** Reducing features while keeping important info (e.g., PCA)
|
| 115 |
+
- **Examples:**
|
| 116 |
+
- Grouping customers by purchasing behavior
|
| 117 |
+
- Compressing images while keeping quality
|
| 118 |
+
""")
|
| 119 |
+
|
| 120 |
+
with st.expander("π‘ Real-life Analogy"):
|
| 121 |
+
st.write("""
|
| 122 |
+
Think of visiting a supermarket where items are grouped by similarity:
|
| 123 |
+
fruits in one section, vegetables in another.
|
| 124 |
+
Nobody told the store which items belong together β they just grouped them by observation.
|
| 125 |
+
""")
|
| 126 |
+
|
| 127 |
+
# ---------- Evaluation Metrics ----------
|
| 128 |
elif page == "Evaluation Metrics":
|
| 129 |
st.title("π Model Evaluation Metrics")
|
| 130 |
+
st.write("Evaluation metrics tell us how well our machine learning model is performing.")
|
| 131 |
+
|
| 132 |
+
with st.expander("π For Classification"):
|
| 133 |
+
st.markdown("""
|
| 134 |
+
- **Accuracy** = Correct predictions / Total predictions
|
| 135 |
+
- **Precision** = Of all predicted positives, how many are actually positive?
|
| 136 |
+
- **Recall** = Of all actual positives, how many did we find?
|
| 137 |
+
- **F1-Score** = Harmonic mean of precision & recall
|
| 138 |
+
- **Confusion Matrix** = Table showing TP, FP, TN, FN
|
| 139 |
+
""")
|
| 140 |
+
|
| 141 |
+
with st.expander("π For Regression"):
|
| 142 |
+
st.markdown("""
|
| 143 |
+
- **MAE (Mean Absolute Error)** = Average absolute difference between predictions and actual values
|
| 144 |
+
- **MSE (Mean Squared Error)** = Average of squared differences
|
| 145 |
+
- **RMSE** = Square root of MSE
|
| 146 |
+
- **RΒ² Score** = Proportion of variance explained by the model
|
| 147 |
+
""")
|
| 148 |
|
| 149 |
+
# ---------- Data Preprocessing ----------
|
| 150 |
+
elif page == "Data Preprocessing":
|
| 151 |
+
st.title("β Data Preprocessing")
|
| 152 |
+
st.write("""
|
| 153 |
+
Preprocessing prepares raw data so that a machine learning model can use it effectively.
|
| 154 |
+
""")
|
| 155 |
+
|
| 156 |
+
with st.expander("π Steps"):
|
| 157 |
+
st.markdown("""
|
| 158 |
+
1. **Handling Missing Values** β Remove or fill in missing data
|
| 159 |
+
2. **Encoding Categorical Data** β Convert text labels to numbers
|
| 160 |
+
3. **Feature Scaling** β Normalize or standardize values
|
| 161 |
+
4. **Removing Outliers** β Detect and handle extreme values
|
| 162 |
+
""")
|
| 163 |
+
|
| 164 |
+
# ---------- Interview Tips ----------
|
| 165 |
+
elif page == "Interview Tips":
|
| 166 |
+
st.title("πΌ ML Interview Tips")
|
| 167 |
+
st.markdown("""
|
| 168 |
+
- Be clear with definitions and examples
|
| 169 |
+
- Explain algorithms with analogies
|
| 170 |
+
- Understand trade-offs between models
|
| 171 |
+
- Practice with real datasets
|
| 172 |
+
""")
|
| 173 |
+
|
| 174 |
+
# ---------- Resources ----------
|
| 175 |
elif page == "Resources":
|
| 176 |
+
st.title("π Useful Resources")
|
| 177 |
st.markdown("""
|
| 178 |
- [Scikit-learn Docs](https://scikit-learn.org/)
|
| 179 |
- [Kaggle Courses](https://www.kaggle.com/learn)
|
| 180 |
- [Google ML Crash Course](https://developers.google.com/machine-learning/crash-course)
|
| 181 |
""")
|
|
|