Predicting the price of a house
This section will deal with building a simple linear model to predict house prices using all the features in the current dataframe
. We will then evaluate the model and try to improve the accuracy by using a more complex model in the latter half of the section.
Getting ready
Visit the following links to understand how linear regression works and how to use the linear regression model in the Scikit Learn library:https://en.wikipedia.org/wiki/Linear_regression
http://www.stat.yale.edu/Courses/1997-98/101/linreg.htm
https://newonlinecourses.science.psu.edu/stat501/node/251/
http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html
How to do it...
- Drop the
Price
column from thex_df
dataframe and save it into a newdataframe
namedx_df2
using the following script:
x_df2 = x_df.drop(['price'], axis = 1)
- Declare a variable named
reg
and equate it to theLinearRegression()
function from...