In Python, when you train LSTM model you can train the model on part of the data. Then at inference you can give it whatever input you like for example 10 recent timesteps that is not part of the training set. It will produce the output. Now can ARIMA operate in the same way? Can we give it input sequence ? Or does it use the training data to predict next steps ?
Below is my code:
import pandas as pd
from statsmodels.tsa.arima.model import ARIMA
import torch
import sys
import math
# Read the dataset from CSV file
df = pd.read_csv('sm_data.csv', header=None)
# Take the first 102 rows as training data and the rest as test data
train_data = df.iloc[:102, :]
test_data = df.iloc[102:, :]
# Iterate over each trend
forecast_results = {}
for column in df.columns:
# Fit ARIMA model on training data
model = ARIMA(train_data[column], order=(10,1,0))
model_fit = model.fit()
# Forecast 36 months ahead
forecast = model_fit.forecast(steps=36)
# Store forecast results
forecast_results[column] = forecast
# Convert forecast results to DataFrame
forecast_df = pd.DataFrame(forecast_results)
# Save forecast results to CSV
forecast_df.to_csv('forecast_results.csv', index=False)
AFAIK you cannot do that. ARIMA models are, differently from ML context, strictly related to the training data itself, so forecasts are based on the historical data where the model was trained on.
On the page of statsmodels, the forecast module takes the following arguments:
ARIMAResults.forecast(steps=1, signal_only=False, **kwargs)
And you cannot specify data taken as input.