Source code of TSAP: Time-Series Additive exPlanations, a novel explainer based on time-series transformations

Read full text
Authors: Iván García‐Magariño
Cited by: 0

Abstract

This dataset contains the complete Python source code of Time-Series Additive exPlanations (TSAP), a novel model-agnostic explainer designed for time-series (TS) machine learning (ML) models. TSAP is based on measuring the impact of controlled TS transformations on the predicted output of forecasting models. The core component of the framework is the class "TsapExplainer", which can be applied to any TS ML model implementing the basic interface "TsModel" (provided as a Python class). The only required method is "predict", which receives a Pandas Series as input and returns a numerical value corresponding to the predicted next value of the series. This design enables compatibility with external ML libraries such as Keras or TensorFlow by implementing a lightweight wrapper class that conforms to the "TsModel" interface and defines the required method. To illustrate the usage of TSAP, this dataset includes the class "LstmExampleTsModel", which implements a Long Short-Term Memory (LSTM) neural network using Keras. This example retrieves stock time-series data through the Yahoo Finance application programming interface (API) and demonstrates how to integrate TSAP with a forecasting model in practice. TSAP supports both local and global explanations. Local explanations analyze the influence of TS transformations on a single prediction, while global explanations characterize the overall behavior of a model based on a group of TS instances. Additional classes and scripts included in the dataset are used for experimentation in the financial domain and for evaluating the explainer using Gummadi’s metrics. These materials were prepared to support the peer-review process of a scientific publication. Although the current version of TSAP includes default transformations related to trend and volatility, the framework is fully extensible. The explainer can receive custom transformation functions as parameters, allowing practitioners to define domain-specific transformations and generate explanations tailored to their particular TS ML models. Researchers and practitioners are encouraged to cite the associated publications and this dataset when using TSAP in academic or professional work.

Fields of Study & Subjects

Explainable Artificial Intelligence (XAI) Time Series Analysis and Forecasting Stock Market Forecasting Methods

Publication details

Journal / source
Mendeley Data
Publication date
17 February 2026
Language
EN
Document type
Dataset