以下代码中用于计算ys的公式是什么?

我不明白用于预测ys以绘制图表的公式是什么。

怎么可能是 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')

回答:

这里你并没有预测 ys,在公式中 xsys 都是你的特征,因此最好将它们命名为 x1x2

这两个公式定义了相同的决策边界:

ys = (-theta[0] - theta[1] * xs) / theta[2]theta[2] * ys = (-theta[0] - theta[1] * xs)

但为了绘制边界,你应该用一个特征来定义另一个特征。

所以这里的 ys 不是你的预测,你的预测是这个表达式符号,它依赖于两个特征 xsys

 theta[0] + theta[1] * xs + theta[2] * ys

在图表上,这条线将你的点分为两组。我附上了你链接中的截图,解释了这一点。

enter image description here

Related Posts

在使用k近邻算法时,有没有办法获取被使用的“邻居”?

我想找到一种方法来确定在我的knn算法中实际使用了哪些…

Theano在Google Colab上无法启用GPU支持

我在尝试使用Theano库训练一个模型。由于我的电脑内…

准确性评分似乎有误

这里是代码: from sklearn.metrics…

Keras Functional API: “错误检查输入时:期望input_1具有4个维度,但得到形状为(X, Y)的数组”

我在尝试使用Keras的fit_generator来训…

如何使用sklearn.datasets.make_classification在指定范围内生成合成数据?

我想为分类问题创建合成数据。我使用了sklearn.d…

如何处理预测时不在训练集中的标签

已关闭。 此问题与编程或软件开发无关。目前不接受回答。…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注