traces

    

A Python library for unevenly-spaced time series analysis.

用于非均匀间隔的时序分析Python库

Why?

Taking measurements at irregular intervals is common, but most tools are primarily designed for evenly-spaced measurements. Also, in the real world, time series have missing observations or you may have multiple series with different frequencies: it's can be useful to model these as unevenly-spaced.

以不规则间隔进行测量是常见的,但大多数工具主要用于均匀间隔测量。 此外,在现实世界中,时间序列缺少观测值,或者可能有多个频率不同的序列:将它们建模为不均匀间隔可能很有用。

Traces was designed by the team at Datascope based on several practical applications in different domains, because it turns out unevenly-spaced data is actually pretty great, particularly for sensor data analysis.

Traces是由Datascope团队根据不同领域的几种实际应用设计的,因为不均匀间隔的数据实际上相当不错,特别是传感器数据分析。

Installation

To install traces, run this command in your terminal:

$ pip install traces

Quickstart: using traces

To see a basic use of traces, let's look at these data from a light switch, also known as Big Data from the Internet of Things.

为了看到traces的基本用法,我们来看看来自灯光开关的这些数据,也称为物联网的大数据。

The main object in traces is a TimeSeries, which you create just like a dictionary, adding the five measurements at 6:00am, 7:45:56am, etc.

traces中的主要实例是一个时间序列,您可以像字典一样创建时间序列,并添加五个测量在6:00am, 7:45:56am, 等等。

>>> time_series = traces.TimeSeries()
>>> time_series[datetime(2042, 2, 1,  6,  0,  0)] = 0 #  6:00:00am
>>> time_series[datetime(2042, 2, 1,  7, 45, 56)] = 1 #  7:45:56am
>>> time_series[datetime(2042, 2, 1,  8, 51, 42)] = 0 #  8:51:42am
>>> time_series[datetime(2042, 2, 1, 12,  3, 56)] = 1 # 12:03:56am
>>> time_series[datetime(2042, 2, 1, 12,  7, 13)] = 0 # 12:07:13am

What if you want to know if the light was on at 11am? Unlike a python dictionary, you can look up the value at any time even if it's not one of the measurement times.

如果你想知道早上11点是否开灯,该怎么办? 与Python字典不同,即使不是测量时间之一,也可以随时查找该值。

>>> time_series[datetime(2042, 2, 1, 11,  0, 0)] # 11:00am
0

The distribution function gives you the fraction of time that the TimeSeries is in each state.

分布函数为您提供TimeSeries处于每种状态的时间分数。

>>> time_series.distribution(
>>>   start=datetime(2042, 2, 1,  6,  0,  0), # 6:00am
>>>   end=datetime(2042, 2, 1,  13,  0,  0)   # 1:00pm
>>> )
Histogram({0: 0.8355952380952381, 1: 0.16440476190476191})

The light was on about 16% of the time between 6am and 1pm.

从上午6点到下午1点,开灯的时间约有16%。

Adding more data...

Now let's get a little more complicated and look at the sensor readings from forty lights in a house.

现在让我们稍微复杂一点,看看房子里四十盏灯的传感器读数。

How many lights are on throughout the day? The merge function takes the forty individual TimeSeries and efficiently merges them into one TimeSeries where the each value is a list of all lights.

一整天有多少灯? 合并函数得到四十个独立的TimeSeries,并将它们有效地合并到一个TimeSeries中,其中每个值都是所有灯光的列表。

>>> trace_list = [... list of forty traces.TimeSeries ...]
>>> count = traces.TimeSeries.merge(trace_list, operation=sum)

We also applied a sum operation to the list of states to get the TimeSeries of the number of lights that are on.

我们还对状态列表应用了一个和运算来获取TimeSeries的灯号数量。

How many lights are on in the building on average during business hours, from 8am to 6pm?

从上午8点到下午6点,营业时间内大楼内开着灯的平均的数量是多少?

>>> histogram = count.distribution(
>>>   start=datetime(2042, 2, 1,  8,  0,  0),   # 8:00am
>>>   end=datetime(2042, 2, 1,  12 + 6,  0,  0) # 6:00pm
>>> )
>>> histogram.median()
17

The distribution function returns a Histogram that can be used to get summary metrics such as the mean or quantiles.

分布函数返回一个直方图,可用于获取汇总指标,如平均值或分位数。

It's flexible/它很灵活

The measurements points (keys) in a TimeSeries can be in any units as long as they can be ordered. The values can be anything.

TimeSeries中的测量点(键)可以是任何单位只要它们可以被命令(翻译的不好,不知道怎么说,这里ordered是命令还安徽排序)。 值可以是任何东西。

For example, you can use a TimeSeries to keep track the contents of a grocery basket by the number of minutes within a shopping trip.

例如,您可以使用TimeSeries通过购物旅行中的分钟数跟踪杂货篮的内容。

>>> time_series = traces.TimeSeries()
>>> time_series[1.2] = {'broccoli'}
>>> time_series[1.7] = {'broccoli', 'apple'}
>>> time_series[2.2] = {'apple'}          # puts broccoli back
>>> time_series[3.5] = {'apple', 'beets'} # mmm, beets

To learn more, check the examples and the detailed reference.

More info

Contributing

Contributions are welcome and greatly appreciated! Please visit our guidelines for more info.

愉快的学习就从翻译开始吧_traces_A Python library for unevenly-spaced time series analysis.相关推荐

  1. 愉快的学习就从翻译开始吧_0-Time Series Forecasting with the Long Short-Term Memory Network in Python

    The Long Short-Term Memory recurrent neural network has the promise of learning long sequences of ob ...

  2. 安卓python编辑器-有了这款编辑器,随时随地都能愉快的学习python!

    原标题:有了这款编辑器,随时随地都能愉快的学习python! 现在学Python的人越来越多,很多小伙伴都非常有激情.利用碎片时间随时随地学习Python, 大家知道Python是一门编程语言,但是学 ...

  3. 如何愉快地学习 Go 语言?来场 Go 之旅吧!

    Go 语言之旅,支持在线敲代码练习的官方入门教程 Go 语言性能很高,非常适于后端网络.分布式编程,因此受到各大互联网公司的青睐. 那么如何学习 Go 语言呢? 其实官方已经为我们准备了一款在线 Go ...

  4. nlp论文-《Neural Machine Translation by Jointly Learning to Align and Translate》-基于联合学习对齐和翻译的神经机器翻译(二)

    1.论文整体框架 1.1 摘要 神经机器翻译的任务定义: 传统神经机器翻译所用的编码器-解码器模型的缺陷: 本文提出一种能够自动搜索原句中与预测目标词相关的神经机器翻译模型: 所提出的模型的效果: 1 ...

  5. nlp论文-《Neural Machine Translation by Jointly Learning to Align and Translate》-基于联合学习对齐和翻译的神经机器翻译(一)

    <Neural Machine Translation by Jointly Learning to Align and Translate>--基于联合学习对齐和翻译的神经机器翻译 作者 ...

  6. 经典神经网络论文超详细解读(三)——GoogLeNet InceptionV1学习笔记(翻译+精读+代码复现)

    前言 在上一期中介绍了VGG,VGG在2014年ImageNet 中获得了定位任务第1名和分类任务第2名的好成绩,而今天要介绍的就是同年分类任务的第一名--GoogLeNet . 作为2014年Ima ...

  7. 经典神经网络论文超详细解读(八)——ResNeXt学习笔记(翻译+精读+代码复现)

    前言 今天我们一起来学习何恺明大神的又一经典之作: ResNeXt(<Aggregated Residual Transformations for Deep Neural Networks&g ...

  8. 【论文翻译】联合学习对齐和翻译的神经机器翻译

    这篇论文在采用RNN编码器-解码器结构做端到端的神经机器翻译的基础上,使得模型可以在预测下一个词的时候,自动地搜索源句子相关的部分,这就是attention机制. 原论文链接: Neural Mach ...

  9. 经典神经网络论文超详细解读(二)——VGGNet学习笔记(翻译+精读)

    前言 上一篇我们介绍了经典神经网络的开山力作--AlexNet:经典神经网络论文超详细解读(一)--AlexNet学习笔记(翻译+精读) 在文章最后提及了深度对网络结果很重要.今天我们要读的这篇VGG ...

最新文章

  1. React Native Android启动白屏的一种解决方案下
  2. VirtualBox 虚拟机复制
  3. 任务太多?学着突破重围
  4. mysql jdbc 绑定变量_jdbc测试mysql数据库sql预解析(绑定变量)
  5. Ansible一键部署CDH
  6. 弱电系统集成(收集)
  7. Spring框架参考手册(4.2.6版本)翻译——第三部分 核心技术 6.10.6 给自动检测组件命名...
  8. 团队作业第六次-团队Github实战训练
  9. iOS开发之UIControlEventEditingChanged失效
  10. 全国高校安徽考区计算机,关于做好2021年上半年全国高校(安徽考区)计算机水平考试报名工作的通知...
  11. python数据分析之(6)简单绘图matplotlib.pyplot
  12. 数字信号处理课程设计---带通滤波器的设计及其matlab实,数字信号处理课程设计---带通滤波器的设计及其MATLAB实现...
  13. sybase 设置默认值_修改Sybase数据库的默认字符集为CP936
  14. 10个精选国外免费空间
  15. Linux网络问题排查
  16. 3D模型欣赏:美杜莎女妖 角色设计完整 造型独特
  17. 如何拆宏碁(acer)笔记本--个人动手更换风扇、清理灰尘
  18. 发json请求,报415错误。POST http://localhost:8080/ 415
  19. 2020亚洲品牌500强榜单发布 ;肯德基中国门店将限时发售植物肉汉堡 | 美通企业日报...
  20. 福州大学数学与计算机科学学院邮编,应用数学年刊期刊_投稿邮箱_杂志_编辑部_审稿_投稿须知...

热门文章

  1. html2canvas的使用方法,html2Canvas使用总结
  2. NLP-机器学习-监督学习-回归
  3. 微信小程序实现按所选条件进行筛选功能
  4. python的本质_python变量的实质
  5. 小白被挖矿木马整emo的一天
  6. (#号开头)颜色代码表
  7. pve cpu监测 温度功耗监测软件
  8. OpenCV cv::TermCriteria 模板类
  9. 什么是ACPI,什么是APIC
  10. 微信公众号粉丝精细化管理