Home Forums Data Science with Python Time series Sales Forecasting in Python

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1803

    Time series Sales Forecasting in Python

    Consider the below data set stored as comma separated csv file.

    Use the 2017 Data to predict the sales in the year 2018. Write a python program that can utilize 2017 Data set and make a prediction for the year 2018 for each month.

    #1807

    Solution :

    Here the first step is to store the sales data in python list.

    SO, first we will create an empty list to store the sales data that exists in index 4 in the csv file.

    Next is to read the csv file line by line and populate the empty list line by line.

    Once we have all the sales data we would create another empty list to store the predictions.

    Now since we need to predictions for the next 12 months we would again iterate from index 12 to 24 (Since we already have data for index below 12).

    Now under each iteration we will apply moving average algorithm to predict the current month’s sales.

    The window of moving average is taken as 3.

    Once the 12 months predictions are made. Then we will use another loop to print the actual sales vs. predicted sales.

    The python and program and its output are as follows:

    Python code for time series sales prediction

    Time Series Sales Prediction Outcome Python

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.