0% found this document useful (0 votes)
4 views5 pages

Linear Regression Sales Analysis

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Linear Regression Sales Analysis

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DATA ANALYSIS(JULY/AUGUST BATCH)

NAME: [Link] SRI


PROJECT – 2

TITLE : LINEAR REGRESSION MODEL

AIM :
To find linear relationship between Sales and Advertising dataset

PROJECT OVERVIEW :
a. imported the necessary library : matplotlib,sklearn,pandas
b. Imported the data
c. Analysed the data
d. Declared feature variable and target variable
e. Plotted scatter plot between X and y
f. Checking and reshaping of the x and y is done
g. Applied model
h. Plotted the Regression Line

PROGRAM:

import [Link] as plt import


pandas as pd
from sklearn.linear_model import LinearRegression
data=pd.read_csv('[Link]')

#analysing the data


print("first and last 5 rows from the given data") print([Link]())
print([Link]())

#decribing the data


print("\nDescribing Data:\n",[Link]())

#checking missing values


print("\nmissing values: \n",[Link]().sum())

#declaring feature and targeted variable x=data['advertising'].values

y=data['sales'].values

#reshaping x reshaped_x =
[Link](-1,1)

#applyiing model model=LinearRegression()

#fitting in model [Link](reshaped_x,y)

#prediction
y_predict= [Link](reshaped_x)
#slope and interception print("\nSlope
and Interception:") print("slope
:",model.coef_[0])
print("interception:",model.intercept_)

#plotting [Link](x,y,color="blue")
[Link](x,y_predict,color="red")
[Link]("advertising")
[Link]("sales")
[Link]("LinearRegression")
[Link]()

OUTPUT:
first and last 5 rows from the given data
advertising sales
0 12.0 15 1
20.5 16 2
21.0 18
3 15.5 27
4 15.3 21 advertising sales
31 31.3 65
32 32.3 17
33 26.4 5
34 23.4 17
35 16.4 1
Describing Data:
advertising sales
count 36.000000 36.000000
mean 24.255556 28.527778
std 6.185118 18.777625
min 12.000000 1.000000
25% 20.300000 15.750000 50%
24.250000 23.000000 75%
28.600000 41.000000 max
36.500000 65.000000

missing values:
advertising 0
sales 0 dtype:
int64

Slope and Interception: slope :


1.9149681259097098 interception:
-17.920837987343283
CONCLUSION :

Thus the linear relationship between Sales and Advertising dataset


plotted using regression.

You might also like