<jupyter_start><jupyter_text>For this code, I took refernce from:    1.https://www.statsmodels.org/stable/generated/statsmodels.tsa.arima_model.ARIMA.html    2.https://www.machinelearningplus.com/time-series/arima-model-time-series-forecasting-python/    3.https://github.com/krishnaik06/ARIMA-And-Seasonal-ARIMA/blob/master/Untitled.ipynb    4.https://machinelearningmastery.com/make-sample-forecasts-arima-python/<jupyter_code>import pandas as pd
from statsmodels.tsa.stattools import adfuller
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
from statsmodels.tsa.arima_model import ARIMA
import numpy as np
import matplotlib.pyplot as plt
rain=pd.read_csv('rain_processed.csv')
#rain.drop(columns=['Unnamed: 0'],inplace=True)
exog=rain['value']
endog=rain['flood'].values<jupyter_output><empty_output><jupyter_text>Checking if data is  stationary<jupyter_code>#Checking for stationary
ad=adfuller(exog)
print('Exog:')
if(ad[1]<=0.5):
    print('Stationary')
else:
    print('Not Stationary')
ad=adfuller(endog)
print('Endog:')
if(ad[1]<=0.5):
    print('Stationary')
else:
    print('Not Stationary')<jupyter_output>Exog:
Stationary
Endog:
Stationary<jupyter_text>Using Autocorrelation and partial correlation to determine p,d,q<jupyter_code>fig, axes = plt.subplots(2)
plt.rcParams.update({'figure.figsize':(9,7), 'figure.dpi':120})
axes[0].plot(exog); axes[0].set_title('No Differencing')
plot_acf(exog, ax=axes[1])
axes[0].plot(exog.diff()); axes[0].set_title('1st Order Differencing')
plot_acf(exog.diff().dropna(), ax=axes[1])<jupyter_output><empty_output><jupyter_text>Setting d=1 and q=1 as setting above values bring about small changes<jupyter_code>axes[1].set(ylim=(0,5))
plot_pacf(exog, ax=axes[1])
axes[1].set(ylim=(0,5))
plot_pacf(exog.diff().dropna(), ax=axes[1])<jupyter_output><empty_output><jupyter_text>p=1  ARIMA<jupyter_code>model = ARIMA(endog=endog, exog=exog,order=(1,1,1))
model_fit=model.fit()
model_fit.plot_predict(dynamic=False)
exog.tail()
rain_prediction=ARIMA(rain['value'],order=(1,1,0))
model = rain_prediction.fit(disp=0)
model.plot_predict(dynamic=False)
out=model.forecast(steps=7)
output=out[0].copy()
output[6]=309
output
model_fit.forecast(steps=7,exog=output,alpha=0.05)<jupyter_output><empty_output><jupyter_text>Trying with SARIMAX<jupyter_code>import statsmodels.api as sm
model=sm.tsa.statespace.SARIMAX(rain['value'],order=(1, 1, 1),seasonal_order=(1,1,1,12))
results=model.fit()
seasonal_out=results.forecast(steps=7)
seas=seasonal_out.values
seas[6]=309
model_fit.forecast(steps=7,exog=seas,alpha=0.05)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16184971098265896, 'fraction_numerical': 0.027360308285163778, 'mean_word_length': 9.062015503875969, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 24, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '207207', 'license': 'MIT', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1038, 'n_words': 129, 'path': 'time_series.ipynb', 'repo_name': 'Thejineaswar/Time-series', 'size': '2595'}