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]:
areaprice
02600550000
13000565000
23200610000
33600680000
44000725000
In [34]:
%matplotlib inline 
plt.xlabel("area")
plt.ylabel("price")
plt.scatter(df.area,df.price,color="red",marker="+")
Out[34]:
<matplotlib.collections.PathCollection at 0x18712b13c88>
In [37]:
newdf = df.drop("price",axis="columns")
newdf
Out[37]:
area
02600
13000
23200
33600
44000
In [39]:
model = linear_model.LinearRegression()
model.fit(newdf,df.price)
Out[39]:
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None, normalize=False)
In [43]:
model.predict([[5000]])
Out[43]:
array([859554.79452055])
In [44]:
model.intercept_
Out[44]:
180616.43835616432

Comments

Popular posts from this blog

spealized the work. Be ready for the future

lest just create a basic bot operation in python

scatterplot/ violon plot /histogram /boxplot