Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created May 28, 2020 16:17
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 codecademydev/8822d965cb552a3c4e2ff66179dda083 to your computer and use it in GitHub Desktop.
Save codecademydev/8822d965cb552a3c4e2ff66179dda083 to your computer and use it in GitHub Desktop.
Codecademy export
import codecademylib3_seaborn
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
# load and investigate the data here:
df= pd.read_csv("tennis_stats.csv")
x=df[['BreakPointsOpportunities']]
y=df[['Winnings']]
print(df.head())
#plt.scatter(x,y)
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.8)
lr=LinearRegression()
lr.fit(x_train,y_train)
lr.score(x_test,y_test)
plt.scatter(x_train,y_train)
y_predict=lr.predict(x_test)
plt.plot(x_test,y_predict,color='blue',linewidth=3)
plt.show()
# perform exploratory analysis here:
## perform single feature linear regressions here:
## perform two feature linear regressions here:
## perform multiple feature linear regressions here:
@satyamchauhan22
Copy link

my first ml project on linear regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment