-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSales_Forecasting.py
More file actions
58 lines (43 loc) · 1.45 KB
/
Sales_Forecasting.py
File metadata and controls
58 lines (43 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
"""time kovai.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1equ9_lMd4ngdjmqQ_fKWArbctPftGPG4
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
data=pd.read_csv("/content/Daily_Public_Transport_Passenger_Boardings_By_Ticket_Type_20240513.csv")
data.head()
data=data.drop(['Paper Ticket'],axis=1)
data
data['Date'] = pd.to_datetime(data['Date'], format='%d-%m-%Y')
df = data.loc[(data['Date'] <= '30-04-2024')]
df.dtypes
sns.set_style('whitegrid')
df.plot(figsize = (13,7), title ='MyWay', color = 'orangered')
plt.show()
df1=df['MyWay']
rolmean = df1.rolling(window=15).mean()
rolstd = df1.rolling(window=15).std()
plt.figure(figsize = (13,7))
orig = plt.plot(df, color = 'green', label = 'Original')
mean = plt.plot(rolmean, color = 'orange', label = 'Rolling Mean')
std = plt.plot(rolstd, color = 'black', label = 'Rolling Std')
plt.legend(loc='best')
plt.title('Rolling Mean & Standard Deviation')
plt.show(block=True)
from statsmodels.tsa.arima.model import ARIMA
model = ARIMA(df1, order=(5,1,0))
fit_model = model.fit()
forecast = fit_model.forecast(steps=7)
print("Forecast for the next 7 days is :")
print(forecast)
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
plt.figure(figsize = (12,7))
plt.subplot(211)
plot_acf(df1, ax=plt.gca(),lags=30)
plt.subplot(212)
plot_pacf(df1, ax=plt.gca(),lags=30)
plt.show()