Spaces:
Sleeping
Sleeping
Update pages/12_Logistic_Regression.py
Browse files29 unmodified lines303132333435363 unmodified lines4041424344454614 unmodified lines616263646566674 unmodified lines7273747576777811 unmodified lines909192939495969720 unmodified lines1181191201211221231243 unmodified lines1281291301311321331344 unmodified lines1391401411421431441458 unmodified lines15415515615715815916016116216316416529 unmodified linesst.markdown("<h1 style='text-align: center;'>๐ Logistic Regression (Theory)</h1>", unsafe_allow_html=True)with st.expander("๐ What is Logistic Regression?"):st.write("""Logistic Regression is a **supervised learning algorithm** used for **classification tasks**.- Mostly used for **binary classification**3 unmodified linesโ ๏ธ Assumption: The data should be **linearly separable** or nearly so.""")with st.expander("โ๏ธ Step vs Sigmoid Function"):st.write("""Initially, people used **step function** for classification:14 unmodified lines- \\( z = 0 \\) โ output = 0.5""")with st.expander("๐งฎ Loss Function in Logistic Regression"):st.write("""Logistic Regression uses **Log Loss** (or Binary Cross Entropy) for optimization:$$4 unmodified lines- Minimize this loss using **Gradient Descent**""")with st.expander("๐ Gradient Descent & Learning Rate"):st.write("""Gradient Descent updates weights to minimize loss:$$11 unmodified lines- **Stochastic (SGD)**: Updates per data point- **Mini-Batch**: Updates per small batch โ widely used""")with st.expander("๐ข Multiclass Logistic Regression"):st.subheader("1๏ธโฃ Softmax Regression")st.write("""Generalizes binary logistic regression to multi-class using **Softmax Function**:20 unmodified linesThen pick the class with the highest confidence score.""")with st.expander("๐งฒ Regularization in Logistic Regression"):st.write("""Regularization helps reduce **overfitting** by penalizing large weights.- **L1 (Lasso)**: \\( \\lambda \\sum |w| \\) โ Feature selection3 unmodified linesโ๏ธ Helps balance **bias vs variance**""")with st.expander("๐ Detecting Multicollinearity"):st.write("""Multicollinearity = when predictors are highly correlated.๐ฏ Check using **VIF (Variance Inflation Factor)**:4 unmodified lines- Applying regularization""")with st.expander("โ๏ธ Hyperparameters in Logistic Regression"):st.table([["penalty", "Regularization type ('l1', 'l2', 'elasticnet', None)"],["dual", "Use dual formulation (for liblinear only)"],8 unmodified lines["l1_ratio", "Used with ElasticNet"],])st.markdown("---")st.markdown("### ๐ Want to see it in action? Open the Colab notebook below:")st.markdown("""<a href='https://colab.research.google.com/drive/1IiZmfkCcMltcE5-r5PbQqRpj_maR_M-f?usp=sharing' target='_blank'>๐ Open Logistic Regression Notebook</a>""", unsafe_allow_html=True)st.success("Logistic Regression is simple yet powerful. Master it before diving into complex models!")29 unmodified lines303132333435363738394041424344454647484950515253543 unmodified lines585960616263646514 unmodified lines80818283848586874 unmodified lines929394959697989911 unmodified lines11111211311411511611711811912020 unmodified lines1411421431441451461471483 unmodified lines1521531541551561571581594 unmodified lines1641651661671681691701718 unmodified lines18018118218318418518618718818919019119229 unmodified linesst.markdown("<h1 style='text-align: center;'>๐ Logistic Regression (Theory)</h1>", unsafe_allow_html=True)section = st.radio("๐ Choose a Topic",["Introduction","Step vs Sigmoid","Loss Function","Gradient Descent","Multiclass Logistic Regression","Regularization","Multicollinearity","Hyperparameters","Colab Notebook"],horizontal=True)# Section Contentif section == "Introduction":st.header("๐ What is Logistic Regression?")st.write("""Logistic Regression is a **supervised learning algorithm** used for **classification tasks**.- Mostly used for **binary classification**3 unmodified linesโ ๏ธ Assumption: The data should be **linearly separable** or nearly so.""")elif section == "Step vs Sigmoid":st.header("โ๏ธ Step vs Sigmoid Function")st.write("""Initially, people used **step function** for classification:14 unmodified lines- \\( z = 0 \\) โ output = 0.5""")elif section == "Loss Function":st.header("๐งฎ Loss Function in Logistic Regression")st.write("""Logistic Regression uses **Log Loss** (or Binary Cross Entropy) for optimization:$$4 unmodified lines- Minimize this loss using **Gradient Descent**""")elif section == "Gradient Descent":st.header("๐ Gradient Descent & Learning Rate")st.write("""Gradient Descent updates weights to minimize loss:$$11 unmodified lines- **Stochastic (SGD)**: Updates per data point- **Mini-Batch**: Updates per small batch โ widely used""")elif section == "Multiclass Logistic Regression":st.header("๐ข Multiclass Logistic Regression")st.subheader("1๏ธโฃ Softmax Regression")st.write("""Generalizes binary logistic regression to multi-class using **Softmax Function**:20 unmodified linesThen pick the class with the highest confidence score.""")elif section == "Regularization":st.header("๐งฒ Regularization in Logistic Regression")st.write("""Regularization helps reduce **overfitting** by penalizing large weights.- **L1 (Lasso)**: \\( \\lambda \\sum |w| \\) โ Feature selection3 unmodified linesโ๏ธ Helps balance **bias vs variance**""")elif section == "Multicollinearity":st.header("๐ Detecting Multicollinearity")st.write("""Multicollinearity = when predictors are highly correlated.๐ฏ Check using **VIF (Variance Inflation Factor)**:4 unmodified lines- Applying regularization""")elif section == "Hyperparameters":st.header("โ๏ธ Hyperparameters in Logistic Regression")st.table([["penalty", "Regularization type ('l1', 'l2', 'elasticnet', None)"],["dual", "Use dual formulation (for liblinear only)"],8 unmodified lines["l1_ratio", "Used with ElasticNet"],])elif section == "Colab Notebook":st.header("๐ Google Colab Notebook")st.markdown("""<a href='https://colab.research.google.com/drive/1IiZmfkCcMltcE5-r5PbQqRpj_maR_M-f?usp=sharing' target='_blank'>๐ Open Logistic Regression Notebook</a>""", unsafe_allow_html=True)st.markdown("---")st.success("Logistic Regression is simple yet powerful. Master it before diving into complex models!")
pages/12_Logistic_Regression.py+43-16