How To Plot Decision Boundaries Between 3 Classes Using Discriminant Functions
I have 3 discriminant functions dividing 2D space into 3 regions. I would like to plot decision boundaries between these regions. I couldn't figure out how to do that using matplot
Solution 1:
I think I achieved desired output.
Instead of assigning difference between functions to z array, I assigned index of function having largest value. Then I used numbers between class labels (or function index) as levels parameter. For example, to draw boundary between class 0 and class 1, I added 0.5 to levels parameter.
z = np.array((g1(x, y), g2(x, y), g3(x, y)))
z = np.argmax(z, axis=0)
cp = plt.contour(x, y, z, colors="k", levels=[0.5, 1.5, 2.5])
Post a Comment for "How To Plot Decision Boundaries Between 3 Classes Using Discriminant Functions"