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 1300cm3
###Step6 Print the predicted output.
## Developed by :K.SANTHANA LAKSHMI
## REGISTER NUMBER :212222240091
import pandas as pd
from sklearn import linear_model
data=pd.read_csv("cars.csv")
x=data[['Weight','Volume']]
y=data[['CO2']]
regr=linear_model.LinearRegression()
regr.fit(x,y)
print('Coefficients:',regr.coef_)
print('Intercept:',regr.intercept_)
predictCO2=regr.predict([[3300,1300]])
print('predicted CO2 for the corresponding weight and volume',predictCO2)
Thus the multivariate linear regression is implemented and predicted the output using python program.