Time Series Analysis: Creating Synthetic Datasets

栏目: IT技术 · 发布时间: 5年前

内容简介:How to create time series datasets with different patternsTime series is a sequence of values ordered in time. We may encounter time series data in pretty much any domain. Weather forecasts, exchange rates, sales data, sound waves are just a few examples.

Time Series Analysis: Creating Synthetic Datasets

How to create time series datasets with different patterns

Photo by NeONBRAND on Unsplash

Time series is a sequence of values ordered in time. We may encounter time series data in pretty much any domain. Weather forecasts, exchange rates, sales data, sound waves are just a few examples. Time series can be any type of data that is represented as an ordered sequence.

In an earlier post , I covered the basic concepts in time series analysis. In this post, we will create time series data with different patterns. One advantage of synthetic datasets is that we can measure the performance of a model and have an idea about how it will perform with real life data.

The common patterns observed in a time series are:

  • Trend: An overall upward or downward direction.
  • Seasonality: Patterns that repeat observed or predictable intervals.
  • White noise: Time series does not always follow a pattern or include seasonality. Some processes produce just random data. This kind of time series is called white noise.

Note: The patterns are not always smooth and usually include some kind of noise . Furthermore, a time series may include a combination of different patterns.

We will use numpy to generate arrays of values and matplotlib to plot the series. Let’s start with importing the required libraries:

import numpy as np
import matplotlib.pyplot as plt%matplotlib inline

We can define a function that takes the arrays as input and create plots:

def plot_time_series(time, values, label):
 plt.figure(figsize=(10,6))
 plt.plot(time, values)
 plt.xlabel("Time", fontsize=20)
 plt.ylabel("Value", fontsize=20)
 plt.title(label, fontsize=20)
 plt.grid(True)

Trend in Time Series

The first plot is the simplest one which is a time series with an upward trend. We create arrays for time and values with a slope. Then pass these arrays as arguments to our function:

time = np.arange(100)
values = time*0.4plot_time_series(time, values, "Upward Trend")

以上所述就是小编给大家介绍的《Time Series Analysis: Creating Synthetic Datasets》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

新媒体文案创作与传播

新媒体文案创作与传播

秋叶、叶小鱼、勾俊伟 / 人民邮电出版社 / 2017-4 / 39.80元

《新媒体文案创作与传播》共分三篇。第1篇是新媒体文案基础篇,主要讲述了新媒体文案的基本概念、新媒体文案的岗位要求和职业能力素养;第二篇是新媒体文案创意实务篇,主要讲述了新媒体文案的创作思路、新媒体文案的写作技巧、爆款新媒体文案的打造、新媒体销售文案的写作、新媒体对文案传播的新要求、新媒体品-牌文案的写作,以及不同媒介的特征及发布形式;第三篇为新媒体文案相关技能补充,主要讲述的是策划能力。 《新媒体......一起来看看 《新媒体文案创作与传播》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具