Last active
May 16, 2021 17:29
-
-
Save Aditya1001001/e5aaeba11f3e36b52f515fe0176cd4ce 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.linear_model import LinearRegression | |
n_samples = 100 | |
X = np.linspace(0, 10, 100) | |
y = X ** 3 + np.random.randn(n_samples) * 100 + 100 | |
lin_reg = LinearRegression() | |
lin_reg.fit(X.reshape(-1, 1), y) | |
model_pred = lin_reg.predict(X.reshape(-1,1)) | |
plt.figure(figsize=(10,8)) | |
plt.scatter(X, y) | |
plt.plot(X, model_pred) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment