Week 09 Coding Exercise

.docx

School

University Of Dallas *

*We aren’t endorsed by this school

Course

BANA 7350

Subject

Aerospace Engineering

Date

Apr 3, 2024

Type

docx

Pages

7

Uploaded by MinisterRook17046

# Getting the current working directory: import os import pandas as pd import matplotlib.pyplot as plt os.chdir(r'C:\Users\divye\Desktop\Forecasting Methods\Data') os.getcwd() # Setting up charting formats: # optional plot parameters plt.rcParams['lines.linewidth'] = 3 plt.rcParams['figure.figsize'] = [14.0, 5.0] plt.rcParams['font.size']= 18 plt.style.available # Check what are the styles available for Chart formats plt.style.use('fivethirtyeight') import os import pandas as pd df=pd.read_csv('HOUST1FNSA.csv',index_col=0,parse_dates=True) df.plot() df.fillna(0) df.index.freq='MS' y=df['HOUST1FNSA'] y
type(y) y.plot() # do decomposition using Statsmodel decomposition = seasonal_decompose(y) decomposition.plot() plt.show() # Seasonal Plot : Done on the dataframe, not on y df['month'] = pd.to_datetime(df.index).month df['year'] = pd.to_datetime(df.index).year df sns.lineplot(x='month',y='HOUST1FNSA',hue='year',data=df)
# now split into train and test train_size = int(len(y) * 0.85) train = y[1:train_size] test = y[train_size:] train test # plotting data train.plot(label='Train') test.plot(label='Test') plt.legend() model = SARIMAX(train,order=(1,1,0),seasonal_order=(0,1,1,24)) results = model.fit()
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help