如何绘制重量超过2的线?

时间:2018-10-05 03:11:13

标签: python matplotlib math plot

所以我有一个具有这种结构的数据集

输入

  • 输入:2个输入[x,y]
  • 范围:-99999-99999

输出

  • 输出:4个输出[0,0,0,1](Onehot编码)
  • 范围:0-1

我要创建的是一个像这样的简单象限。 enter image description here

我想看看单层感知器实际上是如何做到的。

我从here那里获得了这段代码

plot_x = np.array([np.min(x[:, 0] - 10), np.max(x[:, 1]) + 10])

#This is for 2 weights
plot_y = - 1 / W[1] * (W[0] * plot_x + b) # comes from, w0*x + w1*y + b = 0 then y = (-1/w1) (w0*x + b)

plt.scatter(x[:, 0], x[:, 1], c=y, s=100, cmap='viridis')
plt.plot(plot_x, plot_y, color='k', linewidth=2)
plt.xlim([-99999, 99999])
plt.ylim([-99999, 99999])
plt.show()

我的问题是,如何从这些权重中计算plot_y

我(非常)是matplotlib的新手,这是我第一次尝试进行可视化。

据我了解,plot_y会创建一条线来划分类别。

0 个答案:

没有答案