Last active
May 16, 2021 17:29
-
-
Save Aditya1001001/2d0fc9c78dcb2185792a5de799d5f79c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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