<jupyter_start><jupyter_text>Multivariate Linear Regression  Sample problem of predicting home price in monroe, new jersey (USA) Below is the table containing home prices in monroe twp, NJ. Here price depends on **area (square feet), bed rooms and age of the home (in years)**. Given these prices we have to predict prices of new homes based on area, bed rooms and age.   Problem Statement Given these home prices find out price of a home that has,- 3000 sqr ft area, 3 bedrooms, 40 year old- 2500 sqr ft area, 4 bedrooms,  5 year old 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<jupyter_code>import pandas as pd
import numpy as np
from sklearn import linear_model
df = pd.read_csv('Data/homeprices_MV.csv')
df<jupyter_output><empty_output><jupyter_text>**Data Preprocessing: Fill NA values with median value of a column**<jupyter_code>df.bedrooms.median()
df.bedrooms = df.bedrooms.fillna(df.bedrooms.median())
df
reg = linear_model.LinearRegression()
reg.fit(df.drop('price',axis='columns'),df.price)
modelPara = reg.coef_
modelPara
intercept = reg.intercept_
intercept<jupyter_output><empty_output><jupyter_text>**Find price of home with 3000 sqr ft area, 3 bedrooms, 40 year old**<jupyter_code>Pred1 = reg.predict([[3000, 3, 40]])
Pred1
Pred1 = modelPara[0]*3000 + modelPara[1]*3 + modelPara[2]*40 + intercept 
Pred1<jupyter_output><empty_output><jupyter_text>**Find price of home with 2500 sqr ft area, 4 bedrooms,  5 year old**<jupyter_code>Pred2 = reg.predict([[2500, 4, 5]])
Pred2<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09473060982830077, 'fraction_numerical': 0.03256364712847839, 'mean_word_length': 6.041666666666667, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '315498', 'license': 'MIT', 'n_tokens_mistral': 578, 'n_tokens_neox': 518, 'n_words': 198, 'path': '04_MachineLearning/02_MultivariateLinearRegression.ipynb', 'repo_name': 'erkundanec/Data-Science-Full', 'size': '1689'}