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.
Okay. Let's add some noise.
Then we'll try another autocorrelation and another.
Now, let's add them to simulate
a seasonal time series that
has an impact full of events that changes everything.
For example, that might be a financial series
that shows seasonality,
but then something changes like
a failure of the business or big news events.
Now, I'm going to add some impulses and plot them.
Nothing too exciting here yet.
But when I start adding some autocorrelations to this,
then we'll see some of the behavior that we had
discussed earlier where from
our pulse we have a decay away from it
but the decay could be interrupted by another pulse.
This decay could be autocorrelated so that after
the pulse it decays but then the decay autocorrelates.
So we have these decreasing curves.
Hopefully this exploration of
some synthetic data to show some of
the attributes of time-series was
helpful for you to understand some of the terminology.
I have found that synthetic data
like this is very useful if you
want to learn how to use
Machine Learning to understand and predict on data.
In the next lesson, you'll take
the first steps towards predicting
the next values in
a synthetic series before later in the course,
you'll start applying what you've
learned to real-world data.