diff --git a/Jupyter_Notebooks/Chapter_01_Supervised_Learning/02-Linear Classification/02-Linear_Classification.ipynb b/Jupyter_Notebooks/Chapter_01_Supervised_Learning/02-Linear Classification/02-Linear_Classification.ipynb index 0a5f3ae8..5ceb769d 100644 --- a/Jupyter_Notebooks/Chapter_01_Supervised_Learning/02-Linear Classification/02-Linear_Classification.ipynb +++ b/Jupyter_Notebooks/Chapter_01_Supervised_Learning/02-Linear Classification/02-Linear_Classification.ipynb @@ -130,6 +130,39 @@ "# Plot the decision boundary: w1 * x1 + w2 * x2 + b = 0.5\n", "x_vals = np.linspace(-4, 6, 100)\n", "decision_boundary = (-w1 * x_vals - w0 + 0.5) / w2\n", + "# Note: This example uses a regression formulation to illustrate a classification problem.\n", + "# Regression is intended for continuous outputs, while classification is for discrete labels.\n", + "# In this illustrative case, we assume (wrongly, but intentionally for educational purposes) that:\n", + "# - We have two features (x1, x2).\n", + "# - The actual labels are 0 and 1.\n", + "# - The regression model will try to generate outputs as close as possible to 0 and 1 for the corresponding inputs.\n", + "#\n", + "# In other words, we're trying to fit a plane such that when applied to (x1, x2), \n", + "# the output is close to either 0 or 1 depending on the class.\n", + "# The regression model fits a plane of the form: \n", + "# y = w1 * x1 + w2 * x2 + w0\n", + "# After fitting, we obtain w0, w1, and w2. That gives us the plane equation.\n", + "#\n", + "# Since the predicted outputs are expected to cluster around 0 and 1, we can introduce a simple threshold of 0.5 \n", + "# (i.e., the midpoint between 0 and 1) to separate the classes:\n", + "# If predicted y > 0.5 → Class A; else → Class B.\n", + "#\n", + "# To visualize this boundary, we solve:\n", + "# 0.5 = w1 * x1 + w2 * x2 + w0\n", + "# which can be rearranged for x2 as:\n", + "# x2 = -(w1 * x1 + w0 - 0.5) / w2\n", + "# This gives us the decision boundary line to plot.\n", + "#\n", + "# 🔬 Remark: Technically, this model is behaving like a *discriminant function*, \n", + "# since it assigns a score to any input vector and applies a threshold to classify.\n", + "# In fact, the fitted linear function:\n", + "# g(x1, x2) = w1 * x1 + w2 * x2 + w0\n", + "# is formally a linear discriminant function.\n", + "# However, since it was trained using squared error rather than a classification loss, \n", + "# its decision boundary may not be optimal for classification purposes.\n", + "#\n", + "# ⚠️ This is purely an illustrative use of regression for classification, \n", + "# and should NOT be considered an appropriate substitute for proper classification algorithms.\n", "\n", "plt.figure(figsize=(8, 6))\n", "plt.scatter(class_A[:, 0], class_A[:, 1], label='Class A', color='blue')\n",