Monday, 29 January 2018

Predicing Future Sales 2:

Objective:

——To predict the future sales and demand of a product by analysing the previous sales history.
—Multiple Linear Regression algorithm is used here to make predictions based on the previous data.
Introduction:

——As we are dealing with ample amounts of  historical data that includes structured and unstructured data which is to be analysed for  prediction purposes Hadoop ecosystem tools like Hive,Pig,Sqoop,Map Reduce are being used in this project.
—Initially data is loaded from mysql to hdfs using sqoop and the data will be further analysed using Hql(Hive query language).
—Apache pig is a high level data flow platform for execution of map reduce programs of hadoop using pig latin language.

Linear Regression Algorithm:
—To predict the future sales and demand of a product by analysing the previous sales history.
—Multiple Linear Regression algorithm is used here to make predictions based on the previous data.
Y=A+B1X1+B2X2+B3X3+....+BnXn
                or
Y=A+BX
Y ->Dependent Variable
X ->Forecasted Independent Variable.
A ->Y-Intercept
B ->Slope of the line.
         Year (X)
T                Sales(Y)
                 YEAR
                     1   
                     2
                     3
                     4
                     5
                     6
                     7
                     8
                     9
                     10
                     11
                     12
                 SALES           
                      600
                      1550
                      1500
                      1500
                      2400
                      3100
                     2600
                     2900
                     3800
                     4500
                     4000
                     4900
The above are the years corresponding to their sales.Based on the above we will forecast the sales to have in (X=13,14,15)
>Inorder to calculate Y=A+BX
Formulaes:
A=Average(Y)-B(Average(X));;;;;
B=sum(X*Y)-N(mean(X*Y)/sum(X*X)-N(Avg(X)^2);;;
A->Y-Intercept
B->Slope of the line
Mean(Y)=Average
N->Total Datapoints
TIME(X) Sales(Y)   X*Y       X*X 
  1              600        600          1
2                1550       3100          4
3               1500       4500          9
4               1500        6000         16 
5                2400      12000        25
6               3100      18600         36
7               2600      18200        49
8              2900       23200       64
9               3800      34200        81    
10             4500       45000       100
11              4000      44000       121
12            4900        58800       144
total         total       total         total
 78            33,350    2,68,200   650
Average(X)=6.5
Average(Y)=2779.17
Average(X*X)=42.25
Therefore B=359.613
Substitute in the year A
A=441.77
Hence our Equation becomes Y=A+BX
Y ->441.77+359.613X.
X-> The Year We need to forecast.
X->13
Y->441.77+359.613*13
y->5116 is the sales in year 13;
Similarly Calculate for 14,15,16,17,18,.... 
Y14=5476
Y15=5835
Y16=6195