<jupyter_start><jupyter_text>Multiple Linear Regression<jupyter_code>import numpy as np 
import pandas as pd 
import matplotlib.pyplot as plt 
#Import DataSet 
dataset = pd.read_csv("house_data_new.csv",sep=',')
print(dataset.shape)
dataset.head()
corr=dataset.corr()
print(corr)<jupyter_output>id     price  bedrooms  bathrooms  sqft_living  sqft_lot  \
id             1.000000 -0.016762  0.001286   0.005160    -0.012258 -0.132109   
price         -0.016762  1.000000  0.308350   0.525138     0.702035  0.089661   
bedrooms       0.001286  0.308350  1.000000   0.515884     0.576671  0.031703   
bathrooms      0.005160  0.525138  0.515884   1.000000     0.754665  0.087740   
sqft_living   -0.012258  0.702035  0.576671   0.754665     1.000000  0.172826   
sqft_lot      -0.132109  0.089661  0.031703   0.087740     0.172826  1.000000   
floors         0.018525  0.256794  0.175429   0.500653     0.353949 -0.005201   
waterfront    -0.002721  0.266369 -0.006582   0.063744     0.103818  0.021604   
view           0.011592  0.397293  0.079532   0.187737     0.284611  0.074710   
condition     -0.023783  0.036362  0.028472  -0.124982    -0.058753 -0.008958   
grade          0.008130  0.667434  0.356967   0.664983     0.762704  0.113621   
sqft_above    -0.010842  0.6[...]<jupyter_text>HEAT MAP<jupyter_code>import seaborn as sns
sns.heatmap(corr)
feature_cols = ['sqft_living','bathrooms','grade','sqft_above']
space=dataset[feature_cols]
price=dataset['price']
x = np.array(space)
y = np.array(price)
#Splitting the data into Train and Test
from sklearn.model_selection import train_test_split 
xtrain, xtest, ytrain, ytest = train_test_split(x,y,test_size=0.2, random_state=0)
print(ytrain) 
print(ytest)
#Fit Multiple linear regression on Training Set
from sklearn.linear_model import LinearRegression 
regressor = LinearRegression()
regressor.fit(xtrain, ytrain)
print("Training complete.")
#Apply on Test Set 
ypred = regressor.predict(xtest)
print('Predicted Data =\n',ypred)

print('Slope =\n',regressor.coef_)

print('Intercept =\n',regressor.intercept_)
# You can also test with your own data
# sqft_living=2000, bathrooms=2, grade=6, sqft_above=2000
regressor.predict([[2000,2,6,2000]])<jupyter_output><empty_output><jupyter_text>R-SQUARED VALUE<jupyter_code>from sklearn.metrics import r2_score
r2_score(ytest, ypred)<jupyter_output><empty_output><jupyter_text>ERROR<jupyter_code>from sklearn import metrics
print(metrics.mean_absolute_error(ytest,ypred))
print(metrics.mean_squared_error(ytest,ypred))
print(np.sqrt(metrics.mean_squared_error(ytest,ypred)))<jupyter_output>157412.92126076441
53739506907.39486
231817.83129732462
StarcoderdataJupyterStructuredCleanDedup