Implementation of Multivariate Linear Regression Model for Sales Prediction














































Implementation of Multivariate Linear Regression Model for Sales Prediction



  Implementation of Multivariate Linear Regression Model for Sales Prediction




Aim:


     To Implement the multivariate linear regression model for predicting the sales.


Theory:

        

      Multivariate Regression is a supervised machine learning algorithm involving multiple data variables for analysis. A Multivariate regression is an extension of multiple regression with one dependent variable and multiple independent variables. Based on the number of independent variables, we try to predict the output.


     Multivariate Regression is a method used to measure the degree at which more than one independent variable (predictors) and more than one dependent variable (responses), are linearly related.

 



DATASET:



This is a
practical session of linear Regression.So as a prerequisite learn
linearRegression topics before going to do this lab.

first  download the dataset links in this link


Source Code:



import pandas as pd
import matplotlib .pyplot as plt
df = pd.read_csv('Advertising_data.csv')
df.head()
df.describe()
df.isnull().sum()
df.shape
x=df[["TV", "radio", "newspaper"]]
x
y=df["sales"]
y
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)
x_test
print("Regressor slope:   ", l.coef_[0])
print("Regressor intercept:", l.intercept_)
y_pred
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:








More Articles of Eedula Ganesh Reddy:

Name Views Likes
Create a Virtual Private Cloud (VPC) Using AWS Coursera answers 1088 17
WORD ORDER PROBLEM 593 110
Palindrome related problem code - Python 628 123
Music Player - Python 420 31
Implementation of SVM For Spam Mail Detection - Python 569 17
Implementation of SVM For Spam Mail Detection - THEORY 607 209
Implementation of Movie Recommender System 379 57
Implementation of K Means Clustering for Customer Segmentation 610 224
Implementation of Decision Tree Regressor Model for Predicting the Salary of the Employee 409 72
Implementation of Decision Tree Classifier Model for Predicting Employee Churn 443 83
f-strings in Python 455 154
Implementation of Logistic Regression Using Gradient Descent - SOURCE CODE 366 149
Implementation of Logistic Regression Using Gradient Descent - THEORY 427 164
Implementation of Logistic Regression Model to Predict the Placement Status of Student 408 6
Implementation of Multivariate Linear Regression Model for Sales Prediction 1388 27
Colour Detection using Pandas & OpenCV -PYTHON CODE 413 17
Colour Detection using Pandas & OpenCV 420 46
Implementation of Simple Linear Regression Model for Predicting the Marks Scored 350 152
Python Program to generate one-time password (OTP) 609 117
Create a Screen recorder using Python 355 22
Face Detection Using Python 404 20
Linear Regression Lab 1440 180
MAKING A RECTANGULAR SPIRAL IN MS PAINT 391 118
pyautogui library Theory 401 25
Multiple message sending program 410 195
Sklearn 354 156
LinearRegression 377 167

Comments