Spaces:
Sleeping
Sleeping
Bhupen
commited on
Commit
·
033e764
1
Parent(s):
a8e51d7
Add ML intuitions py file
Browse files
app.py
CHANGED
@@ -188,7 +188,33 @@ def main():
|
|
188 |
|
189 |
# Show plot in Streamlit
|
190 |
st.pyplot(fig)
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
# feature discriminatio
|
194 |
# Load dataset
|
|
|
188 |
|
189 |
# Show plot in Streamlit
|
190 |
st.pyplot(fig)
|
191 |
+
|
192 |
+
st.markdown("""
|
193 |
+
When the classes are heavily **intertwined** and not linearly separable, **Logistic Regression** struggles to draw a good boundary. Here's a demonstration.
|
194 |
+
""")
|
195 |
+
|
196 |
+
# Generate an intertwined dataset
|
197 |
+
X, y = make_classification(
|
198 |
+
n_samples=200,
|
199 |
+
n_features=2,
|
200 |
+
n_redundant=0,
|
201 |
+
n_informative=2,
|
202 |
+
n_clusters_per_class=2,
|
203 |
+
class_sep=0.3, # Low separation
|
204 |
+
flip_y=0.1, # Add some label noise
|
205 |
+
random_state=42
|
206 |
+
)
|
207 |
+
|
208 |
+
# Train logistic regression
|
209 |
+
clf = make_pipeline(StandardScaler(), LogisticRegression())
|
210 |
+
clf.fit(X, y)
|
211 |
+
|
212 |
+
# Plot
|
213 |
+
fig, ax = plt.subplots(figsize=(8, 6))
|
214 |
+
plot_decision_boundary(clf, X, y, ax)
|
215 |
+
ax.set_title("Logistic Regression Decision Boundary - intertwined classes")
|
216 |
+
st.pyplot(fig)
|
217 |
+
|
218 |
|
219 |
# feature discriminatio
|
220 |
# Load dataset
|