热线电话:13121318867

登录
2019-02-17 阅读量: 575
如何训练线性回归模型

现在,让我们生成一些随机数据来训练线性回归模型。

# Genrating random linear data

# There will be 50 data points ranging from 0 to 50

x = np.linspace(0, 50, 50)

y = np.linspace(0, 50, 50)

# Adding noise to the random linear data

x += np.random.uniform(-4, 4, 50)

y += np.random.uniform(-4, 4, 50)

n = len(x) # Number of data points

让我们可视化训练数据。

# Plot of Training Data

plt.scatter(x, y)

plt.xlabel('x')

plt.xlabel('y')

plt.title("Training Data")

plt.show()

25.7508
4
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子