如何用两个 numpy 数组拟合 SGDRegressor?

How to fit SGDRegressor with two numpy arrays?

我正在努力学习 SGDRegressor。我生成自己的数据,但我不知道如何将其纳入算法。我收到此错误。

x = np.random.randint(100, size=1000)
y = x * 0.10
clf = linear_model.SGDRegressor()
clf.fit(x, y, coef_init=0, intercept_init=0)

Found arrays with inconsistent numbers of samples: [ 1 1000]

我是 python 和机器学习的新手。我想念什么?

>>> np.random.randint(100, size=1000)

会给你一个 1 x 1000 的数组。 您的功能和目标变量需要在一列中。尝试

>>> x = x.reshape(1000,)