To Create a project on Time series analysis on weather forecasting using ARIMA model in Python and compare with other models.
- Explore the dataset of weather
- Check for stationarity of time series time series plot ACF plot and PACF plot, ADF test, Transform to stationary: differencing
- Determine ARIMA models parameters p, q
- Fit the ARIMA model
- Make time series predictions
- Auto-fit the ARIMA model
- Evaluate model predictions
Developed By: Palamakula Deepika
Reg.No:212221240035
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.tsa.arima.model import ARIMA
from sklearn.metrics import mean_squared_error
data = pd.read_csv("/content/seattle-weather.csv")
data['date'] = pd.to_datetime(data['date'])
data.set_index('date', inplace=True)
def arima_model(data, target_variable, order):
train_size = int(len(data) * 0.8)
train_data, test_data = data[:train_size], data[train_size:]
model = ARIMA(train_data[target_variable], order=order)
fitted_model = model.fit()
forecast = fitted_model.forecast(steps=len(test_data))
rmse = np.sqrt(mean_squared_error(test_data[target_variable], forecast))
plt.figure(figsize=(10, 6))
plt.plot(train_data.index, train_data[target_variable], label='Training Data')
plt.plot(test_data.index, test_data[target_variable], label='Testing Data')
plt.plot(test_data.index, forecast, label='Forecasted Data')
plt.xlabel('Date')
plt.ylabel(target_variable)
plt.title('ARIMA Forecasting for ' + target_variable)
plt.legend()
plt.show()
print("Root Mean Squared Error (RMSE):", rmse)
arima_model(data, 'temp_max', order=(5,1,0))
Thus the program run successfully based on the ARIMA model using python.