How one can create time collection datasets with completely different patterns
Time collection is a sequence of values ordered in time. We might encounter time collection information in just about any area. Climate forecasts, trade charges, gross sales information, sound waves are just some examples. Time collection might be any sort of information that’s represented as an ordered sequence.
In an earlier post, I lined the essential ideas in time collection evaluation. On this submit, we’ll create time collection information with completely different patterns. One benefit of artificial datasets is that we are able to measure the efficiency of a mannequin and have an thought about the way it will carry out with actual life information.
The frequent patterns noticed in a time collection are:
- Development: An total upward or downward route.
- Seasonality: Patterns that repeat noticed or predictable intervals.
- White noise: Time collection doesn’t all the time comply with a sample or embody seasonality. Some processes produce simply random information. This type of time collection is known as white noise.
Be aware: The patterns are usually not all the time easy and often embody some type of noise. Moreover, a time collection might embody a mix of various patterns.
We are going to use numpy to generate arrays of values and matplotlib to plot the collection. Let’s begin with importing the required libraries:
import numpy as np
import matplotlib.pyplot as plt%matplotlib inline
We will outline a perform that takes the arrays as enter and create plots:
def plot_time_series(time, values, label):
The primary plot is the only one which is a time collection with an upward pattern. We create arrays for time and values with a slope. Then go these arrays as arguments to our perform:
time = np.arange(100)
values = time*0.4plot_time_series(time, values, "Upward Trend")