Использую набор данных «экономика» ggplot2 для изучения линейной регрессии.
Почему мой график SGDReгрессии выглядит так?
Код: Выделить всё
x = df.loc[:,'pce'].values.reshape(-1,1)
y = df.loc[:,'psavert'].values.reshape(-1,1)
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x,y, test_size = 0.2)
from sklearn.linear_model import SGDRegressor
sr = SGDRegressor(eta0 = 0.001, verbose = 1)
sr.fit(x_train,y_train.flatten())
plt.scatter(x_train,y_train, s = 5, alpha = 0.3, c = 'blue')
plt.plot(x_train,sr.predict(x_train), c = 'green')
plt.xlabel('pce(billions)')
plt.ylabel('saving rate')
plt.show()
График линейной регрессии
Пытался настроить eta0 или max_iter, но это не работает..
Подробнее здесь: https://stackoverflow.com/questions/793 ... regression