Skip to content

Instantly share code, notes, and snippets.

@ShrashtiSinghal
Last active August 8, 2020 11:45
Show Gist options
  • Save ShrashtiSinghal/003fcd00fea72a7030af27a155e30780 to your computer and use it in GitHub Desktop.
Save ShrashtiSinghal/003fcd00fea72a7030af27a155e30780 to your computer and use it in GitHub Desktop.
Medium article 1
import numpy as np
from sklearn.linear_model import LinearRegression
class predit:
def bestFitLine(self,data):
size=np.array([500,650,700,780,900,1100,1150,2000,2200,2500]).reshape(-1,1)
price=np.array([1000,1500,1600,1770,2200,3000,3500,4400,4600,6000]).reshape(-1,1)
regressionLine=LinearRegression().fit(size,price)
pred=regressionLine.predict(size)
ss=regressionLine.predict(data)
return(ss)
newHouseSize= np.array([1000, 1550,450,920,980]).reshape(-1,1)
Object= predit()
price= Object.bestFitLine(newHouseSize)
print ("Price of {} sq feet house is {}".format(newHouseSize, price ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment