Temporal data is omnipresent in applied machine learning applications. Data often changes over time or is only available or valuable at a certain point in time. For example, market prices and weather conditions change constantly. Temporal data is also often highly discriminative in decision-making tasks. For example, the rate of change and interval between two consecutive heartbeats provides valuable insights into a person's physical health, and temporal patterns of network logs are used to detect configuration issues and intrusions. Hence, it is essential to incorporate temporal data and temporal information in ML applications.![]() |
Time series are the most commonly used representation for temporal data. They consist of uniformly sampled values, which can be useful for representing aggregate signals. However, time series are sometimes not sufficient to represent the richness of available data. Instead, multivariate time series can represent multiple signals together, while time sequences or event sets can represent non-uniformly sampled measurements. Multi-index time sequences can be used to represent relations between different time sequences. In this blog post, we will use the multivariate multi-index time sequence, also known as event sets. Don’t worry, they’re not as complex as they sound.
A simple example
Let's start with a simple example. We have collected sales records from a fictitious online shop. Each time a client makes a purchase, we record the following information: time of the purchase, client id, product purchased, and price of the product.
The dataset is stored in a single CSV file, with one transaction per line:
$ head -n 5 sales.csv timestamp,client,product,price 2010-10-05 11:09:56,c64,p35,405.35 2010-09-27 15:00:49,c87,p29,605.35 2010-09-09 12:58:33,c97,p10,108.99 2010-09-06 12:43:45,c60,p85,443.35 |
Looking at data is crucial to understand the data and spot potential issues. Our first task is to load the sales data into an EventSet and plot it.
# Import Temporian import temporian as tp # Load the csv dataset sales = tp.from_csv("/tmp/sales.csv") # Print details about the EventSet sales |
This code snippet load and print the data:
# Plot "price" feature of the EventSet sales["price"].plot() |
![]() |
We have shown how to load and visualize temporal data in just a few lines of code. However, the resulting plot is very busy, as it shows all transactions for all clients in the same view.
A common operation on temporal data is to calculate the moving sum. Let's calculate and plot the sum of sales for each transaction in the previous seven days. The moving sum can be computed using the Source:https://blog.tensorflow.org/2023/09/forecasting-with-tensorflow-decision-forests-and-temporian.html



