Dav Exp3 66
Dav Exp3 66
Dav Exp3 66
THEORY:-
Multiple linear regression (MLR), also known simply as multiple regression, is a statistical technique that
uses several explanatory variables to predict the outcome of a response variable. The goal of multiple
linear regression is to model the linear relationship between the explanatory (independent) variables
and response (dependent) variables. In essence, multiple regression is the extension of ordinary
least-squares (OLS) regression because it involves more than one explanatory variable.
There is a linear relationship between the dependent variables and the independent variables
The independent variables are not too highly correlated with each other
Here's the formula for multiple linear regression, which produces a more specific calculation:
ß0 is the value of y when all the independent variables are equal to zero.
ß1, ß2, and ßp are the estimated regression coefficients. Each regression coefficient represents the
change in y relative to a one-unit change in the respective independent variable.
Because of the multiple variables, which can be linear or nonlinear, this regression analysis model allows
A linear relationship should exist between the Target and predictor variables.
CODE:-
import pandas as pd
import seaborn as sb
import numpy as np
house = pd.read_csv('https://github.com/YBIFoundation/Dataset/raw/main/Boston.csv')
house.describe()
X = house.drop(['MEDV'],axis=1)
y = house['MEDV']
x=house['RM']
plt.scatter(x,y)
plt.xlabel('Number of rooms')
x=np.array(x)
y=np.array(y)
b1,b0=np.polyfit(x,y,1)
plt.plot(x,b1*x+b0,color='red')
plt.show()
model = LinearRegression()
model.fit(X_train,y_train)
model.intercept_
y_pred = model.predict(X_test)
y_pred
model.coef_
score=r2_score(y_test,y_pred)
OUTPUT:-