Harika22 commited on
Commit
443d386
ยท
verified ยท
1 Parent(s): c8d7a52

Update pages/12_Logistic_Regression.py

Browse files
Files changed (1) hide show
  1. pages/12_Logistic_Regression.py +43 -16
pages/12_Logistic_Regression.py CHANGED
@@ -30,7 +30,25 @@ st.sidebar.markdown("---")
30
 
31
  st.markdown("<h1 style='text-align: center;'>๐Ÿ“ˆ Logistic Regression (Theory)</h1>", unsafe_allow_html=True)
32
 
33
- with st.expander("๐Ÿ“˜ What is Logistic Regression?"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  st.write("""
35
  Logistic Regression is a **supervised learning algorithm** used for **classification tasks**.
36
  - Mostly used for **binary classification**
@@ -40,7 +58,8 @@ with st.expander("๐Ÿ“˜ What is Logistic Regression?"):
40
  โš ๏ธ Assumption: The data should be **linearly separable** or nearly so.
41
  """)
42
 
43
- with st.expander("โš™๏ธ Step vs Sigmoid Function"):
 
44
  st.write("""
45
  Initially, people used **step function** for classification:
46
 
@@ -61,7 +80,8 @@ with st.expander("โš™๏ธ Step vs Sigmoid Function"):
61
  - \\( z = 0 \\) โ†’ output = 0.5
62
  """)
63
 
64
- with st.expander("๐Ÿงฎ Loss Function in Logistic Regression"):
 
65
  st.write("""
66
  Logistic Regression uses **Log Loss** (or Binary Cross Entropy) for optimization:
67
  $$
@@ -72,7 +92,8 @@ with st.expander("๐Ÿงฎ Loss Function in Logistic Regression"):
72
  - Minimize this loss using **Gradient Descent**
73
  """)
74
 
75
- with st.expander("๐Ÿ” Gradient Descent & Learning Rate"):
 
76
  st.write("""
77
  Gradient Descent updates weights to minimize loss:
78
  $$
@@ -90,8 +111,10 @@ with st.expander("๐Ÿ” Gradient Descent & Learning Rate"):
90
  - **Stochastic (SGD)**: Updates per data point
91
  - **Mini-Batch**: Updates per small batch โ†’ widely used
92
  """)
93
-
94
- with st.expander("๐Ÿ”ข Multiclass Logistic Regression"):
 
 
95
  st.subheader("1๏ธโƒฃ Softmax Regression")
96
  st.write("""
97
  Generalizes binary logistic regression to multi-class using **Softmax Function**:
@@ -118,7 +141,8 @@ with st.expander("๐Ÿ”ข Multiclass Logistic Regression"):
118
  Then pick the class with the highest confidence score.
119
  """)
120
 
121
- with st.expander("๐Ÿงฒ Regularization in Logistic Regression"):
 
122
  st.write("""
123
  Regularization helps reduce **overfitting** by penalizing large weights.
124
  - **L1 (Lasso)**: \\( \\lambda \\sum |w| \\) โ†’ Feature selection
@@ -128,7 +152,8 @@ with st.expander("๐Ÿงฒ Regularization in Logistic Regression"):
128
  โš–๏ธ Helps balance **bias vs variance**
129
  """)
130
 
131
- with st.expander("๐Ÿ” Detecting Multicollinearity"):
 
132
  st.write("""
133
  Multicollinearity = when predictors are highly correlated.
134
  ๐ŸŽฏ Check using **VIF (Variance Inflation Factor)**:
@@ -139,7 +164,8 @@ with st.expander("๐Ÿ” Detecting Multicollinearity"):
139
  - Applying regularization
140
  """)
141
 
142
- with st.expander("โš™๏ธ Hyperparameters in Logistic Regression"):
 
143
  st.table([
144
  ["penalty", "Regularization type ('l1', 'l2', 'elasticnet', None)"],
145
  ["dual", "Use dual formulation (for liblinear only)"],
@@ -154,12 +180,13 @@ with st.expander("โš™๏ธ Hyperparameters in Logistic Regression"):
154
  ["l1_ratio", "Used with ElasticNet"],
155
  ])
156
 
157
- st.markdown("---")
158
- st.markdown("### ๐Ÿ““ Want to see it in action? Open the Colab notebook below:")
159
- st.markdown("""
160
- <a href='https://colab.research.google.com/drive/1IiZmfkCcMltcE5-r5PbQqRpj_maR_M-f?usp=sharing' target='_blank'>
161
- ๐Ÿ”— Open Logistic Regression Notebook
162
- </a>
163
- """, unsafe_allow_html=True)
164
 
 
165
  st.success("Logistic Regression is simple yet powerful. Master it before diving into complex models!")
 
30
 
31
  st.markdown("<h1 style='text-align: center;'>๐Ÿ“ˆ Logistic Regression (Theory)</h1>", unsafe_allow_html=True)
32
 
33
+ section = st.radio(
34
+ "๐Ÿ“š Choose a Topic",
35
+ [
36
+ "Introduction",
37
+ "Step vs Sigmoid",
38
+ "Loss Function",
39
+ "Gradient Descent",
40
+ "Multiclass Logistic Regression",
41
+ "Regularization",
42
+ "Multicollinearity",
43
+ "Hyperparameters",
44
+ "Colab Notebook"
45
+ ],
46
+ horizontal=True
47
+ )
48
+
49
+ # Section Content
50
+ if section == "Introduction":
51
+ st.header("๐Ÿ“˜ What is Logistic Regression?")
52
  st.write("""
53
  Logistic Regression is a **supervised learning algorithm** used for **classification tasks**.
54
  - Mostly used for **binary classification**
 
58
  โš ๏ธ Assumption: The data should be **linearly separable** or nearly so.
59
  """)
60
 
61
+ elif section == "Step vs Sigmoid":
62
+ st.header("โš™๏ธ Step vs Sigmoid Function")
63
  st.write("""
64
  Initially, people used **step function** for classification:
65
 
 
80
  - \\( z = 0 \\) โ†’ output = 0.5
81
  """)
82
 
83
+ elif section == "Loss Function":
84
+ st.header("๐Ÿงฎ Loss Function in Logistic Regression")
85
  st.write("""
86
  Logistic Regression uses **Log Loss** (or Binary Cross Entropy) for optimization:
87
  $$
 
92
  - Minimize this loss using **Gradient Descent**
93
  """)
94
 
95
+ elif section == "Gradient Descent":
96
+ st.header("๐Ÿ” Gradient Descent & Learning Rate")
97
  st.write("""
98
  Gradient Descent updates weights to minimize loss:
99
  $$
 
111
  - **Stochastic (SGD)**: Updates per data point
112
  - **Mini-Batch**: Updates per small batch โ†’ widely used
113
  """)
114
+
115
+ elif section == "Multiclass Logistic Regression":
116
+ st.header("๐Ÿ”ข Multiclass Logistic Regression")
117
+
118
  st.subheader("1๏ธโƒฃ Softmax Regression")
119
  st.write("""
120
  Generalizes binary logistic regression to multi-class using **Softmax Function**:
 
141
  Then pick the class with the highest confidence score.
142
  """)
143
 
144
+ elif section == "Regularization":
145
+ st.header("๐Ÿงฒ Regularization in Logistic Regression")
146
  st.write("""
147
  Regularization helps reduce **overfitting** by penalizing large weights.
148
  - **L1 (Lasso)**: \\( \\lambda \\sum |w| \\) โ†’ Feature selection
 
152
  โš–๏ธ Helps balance **bias vs variance**
153
  """)
154
 
155
+ elif section == "Multicollinearity":
156
+ st.header("๐Ÿ” Detecting Multicollinearity")
157
  st.write("""
158
  Multicollinearity = when predictors are highly correlated.
159
  ๐ŸŽฏ Check using **VIF (Variance Inflation Factor)**:
 
164
  - Applying regularization
165
  """)
166
 
167
+ elif section == "Hyperparameters":
168
+ st.header("โš™๏ธ Hyperparameters in Logistic Regression")
169
  st.table([
170
  ["penalty", "Regularization type ('l1', 'l2', 'elasticnet', None)"],
171
  ["dual", "Use dual formulation (for liblinear only)"],
 
180
  ["l1_ratio", "Used with ElasticNet"],
181
  ])
182
 
183
+ elif section == "Colab Notebook":
184
+ st.header("๐Ÿ““ Google Colab Notebook")
185
+ st.markdown("""
186
+ <a href='https://colab.research.google.com/drive/1IiZmfkCcMltcE5-r5PbQqRpj_maR_M-f?usp=sharing' target='_blank'>
187
+ ๐Ÿ”— Open Logistic Regression Notebook
188
+ </a>
189
+ """, unsafe_allow_html=True)
190
 
191
+ st.markdown("---")
192
  st.success("Logistic Regression is simple yet powerful. Master it before diving into complex models!")