0% found this document useful (0 votes)
7 views7 pages

Time Series Practical

The document outlines a Python script for analyzing and forecasting international airline passenger numbers using ARIMA modeling. It includes steps for loading data, checking for missing values, visualizing the time series, creating a differenced series, and fitting an ARIMA(1,1,1) model. Finally, it generates and plots forecasts for the next 36 months.

Uploaded by

daya9112
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views7 pages

Time Series Practical

The document outlines a Python script for analyzing and forecasting international airline passenger numbers using ARIMA modeling. It includes steps for loading data, checking for missing values, visualizing the time series, creating a differenced series, and fitting an ARIMA(1,1,1) model. Finally, it generates and plots forecasts for the next 36 months.

Uploaded by

daya9112
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Name: Dimpal Pramod Sonawane

Roll no. :15

PRN:1132220472

Answer:

import numpy as np

import matplotlib.pyplot as plt

import seaborn as sb

import statsmodels.api as sm

from statsmodels.tsa.arima.model import ARIMA

import pandas as pd

df = pd.read_csv(r"C:\Users\ADMIN\Downloads\5_6321061767917079875.csv", index_col =
"Month", parse_dates = True)

#) Load the dataset and display the first few rows.

df.head()

#b) Check for missing values and handle them appropriately.

df.dropna()
missing_values = df.isnull() #for missing value

missing_values

df_filled = df.fillna(0)# for fill missing value

df_filled

#c) Plot the time series to visualize the sales pattern


plt.plot(df)

plt.xlabel('Year')

plt.ylabel('Passenger Number')

plt.title('Monthly International Airline Passenger Number')

plt.show()

#d) Create the differenced series

diff_df = df.diff().dropna()['#Passengers'].values

print(diff_df)
#e) Plot the autocorrelation and partial autocorrelation plots of the differenced series

fig, ax = plt.subplots(2,1, figsize=(10,8))

sm.graphics.tsa.plot_acf(diff_df, ax=ax[0])

sm.graphics.tsa.plot_pacf(diff_df, ax=ax[1])

plt.show()

#f) Fit an ARIMA (1,1,1) model to the data and print model summary

arima_model = ARIMA(df, order=(1,1,1)).fit()

print(arima_model.summary())
#g) Generate forecasts for the next 36 months.

forecast = arima_model.forecast(steps=36)

forecast
#h) Plot the forecasted values

plt.plot(df, label='Observed')

plt.plot(forecast, label='Forecast')

plt.xlabel('Year')

plt.ylabel('Passenger Numbers')

plt.title('Monthly International Airline Passenger Numbers')

plt.legend()

plt.show()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy