import pandas as pd import numpy as np import matplotlib.pyplot as plt from statsmodels.tsa.arima_model import ARMA # Load coffee sales data coffee_sales = pd.read_csv('coffee_sales.csv', index_col=0, parse_dates=True) # Fit ARMA model to data order = (1, 1) # ARMA(1, 1) model = ARMA(coffee_sales, order=order) result = model.fit() # Predict next 24 hours of coffee sales forecast = result.forecast(steps=24) # Plot forecast plt.plot(coffee_sales, label='Observed') plt.plot(forecast, label='Forecast') plt.legend() plt.show()
import pandas as pd import numpy as np import matplotlib.pyplot as plt from statsmodels.tsa.arima_model import ARMA # Load stock price data stock_prices = pd.read_csv('stock_prices.csv', index_col=0, parse_dates=True) # Fit ARMA model to data order = (2, 1) # ARMA(2, 1) model = ARMA(stock_prices, order=order) result = model.fit() # Plot results plt.plot(stock_prices, label='Observed') plt.plot(result.fittedvalues, color='red', label='ARMA Model') plt.legend() plt.show()In both examples, the package library used for implementing the ARMA model is `statsmodels.tsa.arima_model`.