Decision Boundary Plotting

To plot the decision boundary don’t we just need the parameter’s equation z = 0 to plot it?

Some sources mention we need to run the model over a range of values and use their output somehow…

Also, how do we go about plotting decision boundaries for polynomial equations?

The decision boundary is a function of the weights. If there are two features, then it’s a 2D plot, and you can show the boundary as a contour.

To get the contour where the probability is 0.5, you need to have a grid of weight values for which you compute the predicted value.

1 Like

To get a 2D plot, typically you’d use the two lowest-order features as the horizontal and vertical axes, but compute the predicted values using all of the features.

1 Like

Suppose if the function is f(x) = w1(x1^2) + w2(x2^2) + b. How would you go about plotting this? Assume we have already figured out w1 and w2.

[What I am trying to figure out is the step by step procedure from beyond this point and the entire intuitive logic behind each step, so I can achieve it without relying on functions like contourf (still dk how that works)].

Hello @Abtaal_Aatif,

The question is then how you get the (x_1, x_2) pairs that lead to f(x_1, x_2) = 0, right? One way to get one such pair is substitute x_1 = 0 and solve for x_2 where f(0, x_2) = 0. Can you develop the whole procedure from this on?

That would be a 3D plot, since given w1 and w2, you would plot x1 and x2 on the horizontal axes, and f(x) on the vertical axis.

So, I fix a value for one variable and calculate value for the other one, and repeat this over the domains of both variables (nested loop). Afterwards, I just plot the correct values which lead to 0.5. Correct?

No, for now, I only intend on plotting the 2-D variant of the graph with x1 and x2 on x-axis and y-axis respectively.

All the pairs you derived need to satisfy f(x_1, x_2) =0, and so all those pairs satisfy sigmoid(f(x_1, x_2)) = 0.5, and all those pairs are on the boundary. Plotting those pairs gives you the boundary.

2 Likes

Got it. Thank you so much :slight_smile: