4. Autoregression
Activity 4.01: Autoregression Model Based on Periodic Data
- Import the necessary packages, classes, and libraries.
Note
This activity will work on an earlier version of pandas, ensure that you downgrade the version of pandas using the command:
pip install pandas==0.24.2
The code is as follows:
import pandas as pd import numpy as np from statsmodels.tsa.ar_model import AR from statsmodels.graphics.tsaplots import plot_acf import matplotlib.pyplot as plt
- Load the data and convert the
Date
column todatetime
:df = pd.read_csv('../Datasets/austin_weather.csv') df.Date = pd.to_datetime(df.Date) print(df.head()) print(df.tail())
The output for
df.head()
should look as follows:The output for
df.tail()
should look as follows: - Plot the complete set of average temperature values (
df.TempAvgF
) withDate
on the x axis:fig, ax = plt.subplots(figsize = (10, 7)) ax.scatter(df.Date, df.TempAvgF) plt...