Spaces:
Sleeping
Sleeping
| 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(""" | |
| <style> | |
| .main-title { | |
| font-size: 3rem; | |
| color: #004080; | |
| font-weight: 700; | |
| text-align: center; | |
| margin-bottom: 0.5rem; | |
| } | |
| .subtitle { | |
| font-size: 1.2rem; | |
| color: #555; | |
| text-align: center; | |
| margin-bottom: 2rem; | |
| } | |
| .note-box { | |
| background-color: #f9f9f9; | |
| padding: 1rem; | |
| border-radius: 10px; | |
| box-shadow: 0 2px 8px rgba(0,0,0,0.05); | |
| margin-bottom: 1rem; | |
| } | |
| </style> | |
| """, 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('<div class="main-title">π Machine Learning Notes</div>', unsafe_allow_html=True) | |
| st.markdown('<div class="subtitle">Your personal guide to mastering ML concepts!</div>', 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('<div class="note-box">', 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('</div>', 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) | |
| """) | |