To write a python program to implement multivariate linear regression and predict the output.
- Hardware – PCs
- Anaconda – Python 3.7 Installation / Moodle-Code Runner
import pandas as pd.
Read the csv file.
Get the value of X and y variables
Create the linear regression model and fit.
Predict the CO2 emission of a car where the weight is 2300kg, and the volume is 1300cm cube.
Developed by: SORNA KUMAR S
Rgister number: 212223230210
import pandas as pd
from sklearn import linear_model
df=pd.read_csv("car.csv")
a=df[['Weight','Volume']]
b=df[['CO2']]
regr=linear_model.LinearRegression()
regr.fit(a,b)
print("Coefficient: ",regr.coef_)
print("Intercept:",regr.intercept_)
print("Account",regr.predict([[3300,1300]]))
Thus the multivariate linear regression is implemented and predicted the output using python program.