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 560 17
WORD ORDER PROBLEM 527 110
Palindrome related problem code - Python 555 123
Music Player - Python 347 31
Implementation of SVM For Spam Mail Detection - Python 429 17
Implementation of SVM For Spam Mail Detection - THEORY 510 209
Implementation of Movie Recommender System 322 57
Implementation of K Means Clustering for Customer Segmentation 534 224
Implementation of Decision Tree Regressor Model for Predicting the Salary of the Employee 304 72
Implementation of Decision Tree Classifier Model for Predicting Employee Churn 376 83
f-strings in Python 389 154
Implementation of Logistic Regression Using Gradient Descent - SOURCE CODE 303 149
Implementation of Logistic Regression Using Gradient Descent - THEORY 341 164
Implementation of Logistic Regression Model to Predict the Placement Status of Student 319 6
Implementation of Multivariate Linear Regression Model for Sales Prediction 1305 27
Colour Detection using Pandas & OpenCV -PYTHON CODE 339 17
Colour Detection using Pandas & OpenCV 352 46
Implementation of Simple Linear Regression Model for Predicting the Marks Scored 283 152
Python Program to generate one-time password (OTP) 464 117
Create a Screen recorder using Python 288 22
Face Detection Using Python 347 20
Linear Regression Lab 1350 180
MAKING A RECTANGULAR SPIRAL IN MS PAINT 310 118
pyautogui library Theory 315 25
Multiple message sending program 350 195
Sklearn 279 156
LinearRegression 315 167

Comments