Let's take a look at time series and

the various attributes of time series using Python.

This notebook is available as part of

the course and I'll provide a link to it.

I recommend that you watch this video first

and then try the notebook for yourself afterwards.

I'll start by running the nodes containing

the imports as well as a couple of helper functions.

One to plot the series and one to return a trend.

So now, let's plot our first very simple time series.

Even though it's a straight line,

it's also an example of the time series.

The x-axis in this case is time and

the y value is the value of the function at that time.

Next, we'll take a look at adding

a seasonal pattern to our time series.

These functions contain a seasonal pattern and

then seasonality that just uses the same pattern.

We'll now plot that.

As we investigate the graph,

we can see clear peaks and troughs.

But in addition to that,

there are smaller, regular spikes.

This could be seen as a rough simulation

of a seasonal value.

For example, maybe profits for shop that

are negative on the day the store is closed,

peaking a little the day after,

decaying during the week

and then peaking again on the weekend.

What if we now add a trend to this so that the seasonal

data while still following the

pattern increases over time?

Maybe simulating a growing business so when we plot it,

we'll see the same pattern but

with an overall upward trend.

What if we now add another feature that's

common in time series, noise?

Here's a function that add

some noise to a series and when

we call that and plot the results

and their impact on our time series,

we now get a very noisy series,

but one which follows

the same seasonality as we saw earlier.

It's interesting because at this point,

the human eye may miss a lot of

the seasonality data but

a computer will hopefully be able to spot it.

Next we can explore a little bit of Autocorrelation,

but first here are a couple of

functions that can add it for you.

Here is where we add

the autocorrelation to the series and plot it.

There are two different autocorrelation functions and

I'll plot both so that you can see the effects of each.

This one is particularly interesting because you can see

the repeated pattern despite different scales.

There is a pattern and then a sharp fall off followed by

the same pattern on a smaller scale

with the same fall off,

which is then shrunk et cetera.

If I change autocorrelation functions and run it again,

we can then see the other function.