Skip to content

Commit d3f7890

Browse files
authored
Time and time series core concept improvements (#84)
1 parent 18c753e commit d3f7890

2 files changed

Lines changed: 70 additions & 22 deletions

File tree

spiceaidocs/content/en/concepts/_index.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,3 @@ If a time is not specified, the resulting recommendation query time will default
5757
[Training Rewards]({{<ref "reference/pod#rewards">}}) are code definitions in Python that tell the Spice.ai AI Engine how to train the neural networks to achieve the desired goal. A reward is defined for each action specified in the pod.
5858

5959
In the future we will expand the languages we support for writing the reward functions in. [Let us know](mailto:hey@spiceai.io) which language you want to be able to write your reward functions in!
60-
61-
## Time
62-
63-
Time is a fundamental building block for the Spice.ai project. Spice.ai can natively understand how to process time series data, whether that data is streamed in a continuous manner or is batched into larger timeframes.
64-
65-
Taking a pod manifest and creating multiple pods with different time parameters will result in pods that can learn how to give recommendations for actions at different time frames. (i.e. should an action be taken once every second or once every day)
66-
67-
### Epoch
68-
69-
An epoch defines the beginning, or start, of the data stream. If Spice.ai receives data from before the epoch time, it is not used during training. If the epoch is omitted, the epoch is inferred to be `now` - `period`.
70-
71-
### Period
72-
73-
A period is the total span of time that is considered for a pod. The end of the data stream that Spice.ai will look at is the `epoch` + `period`.
74-
75-
### Interval
76-
77-
The interval is the time span that Spice.ai uses as a single input to the neural networks that power Spice.ai. Attempting to get a recommendation without Spice.ai having at least one intervals worth of data will result in an error.
78-
79-
### Granularity
80-
81-
The granularity is the smallest unit of time that specifies how many timesteps there are in an interval. The granularity cannot be larger than the interval. When streaming data in a continuous manner, the Spice.ai runtime can give a new recommendation for action after each new granularity's worth of data is collected.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
type: docs
3+
title: "Time"
4+
linkTitle: "Time"
5+
weight: 5
6+
description: "The concept of Time and Time-Series in Spice.ai"
7+
---
8+
9+
Spice.ai is a time series AI platform, so time is one of Spice.ai's most fundamental and core concepts.
10+
11+
## What is time series data?
12+
13+
Time series data is a series of timestamped data points or events indexed in time order. In Spice.ai, these data points are called Observations. For example, temperature sensor readings on an interval or a daily stock price are examples of time series data. Time series data applies to many domains, including analytics, finance, health and biometrics, IoT and industrial, security, and application monitoring. To learn more, Wikipedia has a comprehensive article on [time series](https://en.wikipedia.org/wiki/Time_series), and InfluxData has published a very informative article, [What is time series data?](https://www.influxdata.com/what-is-time-series-data/)
14+
15+
## Why time series AI?
16+
17+
One definition of artificial intelligence proposed by [Hado van Hasselt from DeepMind](https://www.youtube.com/watch?v=TCCjZe0y4Qc&list=PLqYmG7hTraZDVH599EItlEWsUOsJbAodm) is "to be able to learn to make decisions to achieve goals." Using this definition can conclude that these decisions are made over time to achieve an application's goals. Thus, time and time-series data can be seen as fundamental concepts when developing an application's intelligence.
18+
19+
## Time series in Spice.ai
20+
21+
Spice.ai natively ingests, processes, and learns from time series data. There are three core time series concepts in Spice.ai:
22+
23+
- A time series **Period** and its period **Epoch**
24+
- Consecutive **intervals** or windows of time series observations
25+
- The smallest **granularity** of time in the series
26+
A visualization of these concepts over a timeline is below:
27+
28+
<img width="782" alt="spiceai-time" src="https://user-images.githubusercontent.com/80174/144559519-fc875d71-b43f-402a-ba2e-6754ebba9df0.png">
29+
30+
Each of these concepts translates to developer configurable parameters in the Spicepod. For example, the Trader Sample uses these pod parameters in its manifest:
31+
32+
```yaml
33+
name: trader
34+
params:
35+
period: 30m
36+
interval: 30s
37+
granularity: 5s
38+
```
39+
40+
If not provided in the manifest, Spicepods will default to a period of **3 days**, intervals of **1 min**, and granularity of **10 seconds**. The period epoch will default to a dynamic epoch of the current time minus the period. In this mode, the period becomes a sliding window over time.
41+
42+
See reference documentation for [Spicepod params]({{<ref "reference/pod#params">}}).
43+
44+
### Period
45+
46+
The `period` defines the entire timespan the Spicepod will use for learning and decision-making.
47+
48+
Thus the time series period has a start time of `epoch` and an end time of `epoch` + `period`.
49+
50+
### Period Epoch
51+
52+
The period `epoch` defines the beginning, or start, of the Spicepod's time series data. Spice.ai will discard data timestamped before the epoch time.
53+
54+
The epoch defaults to the current time - `period`.
55+
56+
### Interval
57+
58+
The `interval` defines the interval or window of time the AI engine uses to learn.
59+
60+
The first interval of data, from `epoch` to `epoch` + `interval` is considered pre-training or "warm-up" data. At least one interval's worth of data is required before the AI engine can learn and make a decision recommendation.
61+
62+
The AI engine then trains on consecutive data intervals for the rest of the period to learn.
63+
64+
### Granularity
65+
66+
The `granularity` defines the smallest unit of time series data. The granularity can be conceptualized in practice as the time a decision is valid. For example, a decision to turn on or off an air conditioner would be valid for a `granularity` unit of time.
67+
68+
Spice.ai will aggregate observations within a granularity timespan. This aggregation results in granularity-sized "ticks" or time-steps in the series.
69+
70+
Each consecutive training interval advances by a unit of granularity over the entire period. Thus, the granularity cannot be larger than the interval.

0 commit comments

Comments
 (0)