Code Monkey home page Code Monkey logo

implementation-of-multivariate-linear-regression-model-for-sales-prediction's Introduction

Implementation-of-Multivariate-Linear-Regression-Model-for-Sales-Prediction

Aim:

To write a program to implement the multivariate linear regression model for sales prediction.

Equipment's Required:

  1. Hardware โ€“ PCs
  2. Anaconda โ€“ Python 3.7 Installation / Moodle-Code Runner

Algorithm:

STEP 1:

Import the required libraries.

STEP 2:

Read the csv file using pandas.

STEP 3:

Declare X and Y variable with respect to the dataset.

STEP 4:

Predict the values.

STEP 5:

Using Mean Squared Error find the required line that fits the data.

STEP 6:

Print the Mean Squared Error and R squared error.

STEP 7:

End the program.

Program:

/*
Program to implement the multivariate linear regression model for sales prediction.
Developed by: Syed Abdul Wasih H
RegisterNumber:  212221240057
*/
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('Advertising_data.csv')
df.head()
df.describe()
df.isnull().sum()
x = df[['TV','Radio','Newspaper']]
y = df["Sales"]
from sklearn.model_selection import train_test_split
x_train, x_test,y_train,y_test = train_test_split(x,y,test_size=0.2, random_state=101)
from sklearn.linear_model import LinearRegression
l = LinearRegression()
l.fit(x_train,y_train)
y_pred = l.predict(x_test)
print("Regression Slope: ",l.coef_[0])
print("Regression Intercept:",l.intercept_)
from sklearn import metrics
MSE = metrics.mean_squared_error(y_test,y_pred)
print("MSE is {}".format(MSE))
r2 = metrics.r2_score(y_test,y_pred)
print("R Squared Error is {} ".format(r2))
l.predict([[150.3,240.5,234.5]])

Output:

output

Result:

Thus the program to implement the multivariate linear regression model for sales prediction is written and verified using python programming.

implementation-of-multivariate-linear-regression-model-for-sales-prediction's People

Contributors

akilamohan avatar abdulwasih2003 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.