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/e5aaeba11f3e36b52f515fe0176cd4ce to your computer and use it in GitHub Desktop.
Save Aditya1001001/e5aaeba11f3e36b52f515fe0176cd4ce 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.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