python-time-series-forecasting/2023-04.ipynb
2023-04-29 10:57:42 +04:00

67 KiB

In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

ts = pd.read_csv("/kaggle/input/features-cout-by-week/Features count.csv")
ts.plot()
plt.grid()
plt.show()
In [2]:
moving_avg = ts.rolling(4).mean()
ts.plot()
plt.plot(moving_avg, color='green', label='Moving average')
plt.legend()
plt.grid()
In [ ]:
from statsmodels.tsa.holtwinters import ExponentialSmoothing 
model = ExponentialSmoothing(ts, trend="additive", seasonal="additive", seasonal_periods=5)
fit1 = model.fit()
pred1 = fit1.forecast(5)

plt.plot(ts, label='Features count')
plt.plot(pred1, color='red', label='Holt-Winters forecast')
plt.legend()
plt.grid()
In [ ]:
ts = pd.read_csv("/kaggle/input/testing-time-by-week/Testing time.csv")
model = ExponentialSmoothing(ts, trend="additive", seasonal="additive", seasonal_periods=7)
fit1 = model.fit()
pred1 = fit1.forecast(10)

plt.plot(ts, label='Testing time')
plt.plot(pred1, color='red', label='Holt-Winters forecast')
plt.legend()
plt.grid()