Skip to content

Instantly share code, notes, and snippets.

@Aditya1001001
Last active May 16, 2021 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aditya1001001/2d0fc9c78dcb2185792a5de799d5f79c to your computer and use it in GitHub Desktop.
Save Aditya1001001/2d0fc9c78dcb2185792a5de799d5f79c to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
% matplotlib inline
from sklearn.preprocessing import PolynomialFeatures
n_samples = 100
X = np.linspace(0, 10, 100)
y = X ** 3 + np.random.randn(n_samples) * 100 + 100
poly_reg = PolynomialFeatures(degree=2)
X_poly = poly_reg.fit_transform(X.reshape(-1, 1))
lin_reg_2 = LinearRegression()
lin_reg_2.fit(X_poly, y.reshape(-1, 1))
y_pred = lin_reg_2.predict(X_poly)
plt.figure(figsize=(10,8))
plt.scatter(X, y)
plt.plot(X, y_pred)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment