# codind:utf-8 from sklearn.linear_model import SGDRegressor,LinearRegression,Ridge from sklearn.preprocessing import PolynomialFeatures import numpy as np import matplotlib.pyplot as plt x = np.arange(-10,10,0.1).reshape(-1,1) y = np.sin(x) + np.random.randn(len(x),1) # y = y.reshape(-1) poly_reg =PolynomialFeatures(degree=9) X_ploy =poly_reg.fit_transform(x) print(X_ploy.shape) lin_reg=LinearRegression() lin_reg.fit(X_ploy,y) y_pred = lin_reg.predict(X_ploy) plt.scatter(x,y,s=4) plt.plot(x,y_pred,'r*') plt.show()