linear regression of area and price
import pandas as pd
import numpy as np
from sklearn import linear_model
import matplotlib.pyplot as plt
In [31]:
df = pd.read_csv("areadata.csv")
df
Out[31]:
In [34]:
%matplotlib inline
plt.xlabel("area")
plt.ylabel("price")
plt.scatter(df.area,df.price,color="red",marker="+")
Out[34]:
In [37]:
newdf = df.drop("price",axis="columns")
newdf
Out[37]:
In [39]:
model = linear_model.LinearRegression()
model.fit(newdf,df.price)
Out[39]:
In [43]:
model.predict([[5000]])
Out[43]:
In [44]:
model.intercept_
Out[44]:
Comments
Post a Comment