Git Product home page Git Product logo

multivariate-linear-regression's Introduction

Implementation of Multivariate Linear Regression

Aim

To write a python program to implement multivariate linear regression and predict the output.

Equipment’s required:

  1. Hardware – PCs
  2. Anaconda – Python 3.7 Installation / Moodle-Code Runner

Algorithm:

Step 1:

Import Pandas module

Step 2:

Import linear_module from sklearn

Step 3:

Declare data frame df to read the csv file

Step 4:

Declare variable X equal to df with two arguments Weight and Volume

Step 5:

Declare variable y equal to df with an argument CO2

Step 6:

Declare a variable regr equal to linear_model.LinearRegression()

Step 7:

declare regr.fit(X,y)

Step 8:

Print regr.coeff_

Step 9:

Print regr.intercept_

Step 10:

Declare variable predictedCO2 equal to regr.predict with two arguments 33300, 1300

Step 11:

Print variable predictedCO2

Program:

"Cars.Csv"
V\import pandas as pd
from sklearn import linear_model
import matplotlib.pyplot as plt

df=pd.read_csv("cars.csv")

X=df[['Weight','Volume']]
y=df['CO2']

regr = linear_model.LinearRegression()
regr.fit(X,y)

#Coefficients and intercepts of Model

print('Coefficients: ', regr.coef_)
print('Intercept:',regr.intercept_)

#predict the c02 emission of a car where the weight is 300kg,and the volume is 1300cm3

predictedCO2= regr.predict([[330,130]])

print('Predicted CO2 for the corresponding weight and volume',predictedCO2)

Output:

GitHub Logo

Result

Thus the multivariate linear regression is implemented and predicted the output using python program.

multivariate-linear-regression's People

Contributors

sdmdzahi7 avatar etjabajasphin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.