vertopal.com_2_linear_regression_multivariate
vertopal.com_2_linear_regression_multivariate
Given these home prices find out price of a home that has,
We will use regression with multiple variables here. Price can be calculated using following
equation,
Here area, bedrooms, age are called independant variables or features whereas price is a
dependant variable
import pandas as pd
import numpy as np
from sklearn import linear_model
df = pd.read_csv('homeprices.csv')
df
df.bedrooms.median()
4.0
df.bedrooms = df.bedrooms.fillna(df.bedrooms.median())
df
reg.coef_
reg.intercept_
221323.00186540408
Find price of home with 3000 sqr ft area, 3 bedrooms, 40 year old
reg.predict([[3000, 3, 40]])
array([498408.25158031])
498408.25157402386
Find price of home with 2500 sqr ft area, 4 bedrooms, 5 year old
reg.predict([[2500, 4, 5]])
array([578876.03748933])
Exercise
In exercise folder (same level as this notebook on github) there is hiring.csv. This file contains
hiring statics for a firm such as experience of candidate, his written test score and personal
interview score. Based on these 3 factors, HR will decide the salary. Given this data, you need to
build a machine learning model for HR department that can help them decide salaries for future
candidates. Using this predict salaries for following candidates,
Answer