[英]What formula is being used to calculate ys in the following code?
I'm not able to understand the formula for predicting the ys to plot the graph. 我无法理解用于预测绘制图表的ys的公式。
How can it be ys = (-theta[0] - theta[1] * xs) / theta[2]
? ys = (-theta[0] - theta[1] * xs) / theta[2]
怎么可能?
fig, axes = plt.subplots(1, 3, sharex=True, sharey=True, figsize=(12, 3))
axes = axes.ravel()
for k, theta in enumerate(tha[:3]):
ax = axes[k]
xs = np.arange(0, 1, 0.1)
ys = (-theta[0] - theta[1] * xs) / theta[2]
ax.plot(xs, ys, lw=0.5)
dfa.query('label == 1').plot.scatter(x='x1', y='x2', ax=ax, color='blue')
dfa.query('label == -1').plot.scatter(x='x1', y='x2', ax=ax, color='red')
Here you don't predict ys
, in the formula both xs
and ys
are your features, so probably better name them x1
and x2
. 在这里,您不会预测ys
,在公式中xs
和ys
都是您的特征,因此最好将它们命名为x1
和x2
。
This formulas both define the same decision boundary: 这两个公式都定义了相同的决策边界:
ys = (-theta[0] - theta[1] * xs) / theta[2]
theta[2] * ys = (-theta[0] - theta[1] * xs)
But to plot the boundary you should define one feature with other. 但是要绘制边界,您应该定义一个特征和另一个特征。
So here ys
are not your predictions your prediction is the sign of this expression which depends of two features xs
and ys
: 因此,这里ys
不是您的预测,您的预测是该表达式的符号,它取决于xs
和ys
两个特征:
theta[0] + theta[1] * xs + theta[2] * ys
on the plot this is line which divide your points in two groups. 在图中,这是将您的点分为两组的线。 I attached screenshot from your link where this describes. 我附上了您描述此链接的屏幕截图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.