From a136feac0734c72ad39e681386e0df27cd133b64 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 21 Feb 2021 10:07:19 +0100 Subject: Add decision boundary --- logistic_regression/binary.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'logistic_regression/binary.py') diff --git a/logistic_regression/binary.py b/logistic_regression/binary.py index 1c3f608..ab0dad4 100755 --- a/logistic_regression/binary.py +++ b/logistic_regression/binary.py @@ -97,8 +97,12 @@ scatter=plt.scatter(x_1,x_2,c=np.round(h(x_1,x_2)),marker="o") handles, labels = scatter.legend_elements(prop="colors", alpha=0.6) legend = ax.legend(handles, ["Class A","Class B"], loc="upper right", title="Legend") -x=np.arange(0,10,0.2) -plt.plot([1,2],[2,2]) +# Plot decision boundaries +x=np.arange(0,10,0.01) +y=-w1/w3 +(w2/-w3)*x +plt.fill_between(x,y,np.min(y),alpha=0.2) +plt.fill_between(x,y,np.max(y),alpha=0.2) +plt.plot(x,y,"--") # Save plt.tight_layout() -- cgit v1.2.3