擅长:python、mysql、java
<p>根据您编写<code>decision_boundary</code>的方式,您将希望使用<code>contour</code>函数,如Joe在上面所述。如果只需要边界线,可以在0级别绘制单个轮廓:</p>
<pre><code>f, ax = plt.subplots(figsize=(7, 7))
c1, c2 = "#3366AA", "#AA3333"
ax.scatter(*x1_samples.T, c=c1, s=40)
ax.scatter(*x2_samples.T, c=c2, marker="D", s=40)
x_vec = np.linspace(*ax.get_xlim())
ax.contour(x_vec, x_vec,
decision_boundary(x_vec, mu_vec1, mu_vec2),
levels=[0], cmap="Greys_r")
</code></pre>
<p>这使得:</p>
<p><img src="https://i.stack.imgur.com/5AWVQ.png" alt="enter image description here"/></p>