For this code of polynomial regression implemented in python with sklearn
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
import pandas as pd
m=100
X=6*np.random.rand(m,1)-3
y=0.5*X**3+X+2+np.random.rand(m,1)
poly_features=PolynomialFeatures(3)
X_poly=poly_features.fit_transform(X)
lin_reg=LinearRegression()
X_new=[[0],[3]]
lin_reg.fit(X_poly,y)
plt.plot(X,y,"b.")
plt.plot(X, lin_reg.predict(poly_features.fit_transform(X)), "r-")
plt.show()
The output is showing as
But I wanted to get a smooth prediction line. How to get it?