tpcp: Tiny Pipelines for Complex Problems - A set of framework independent helpers for algorithms development and evaluation

Arne Küderle, Robert Richer, Raul C. Sîmpetru, Bjoern M. EskofierJ. Open Source Softw 2023 · DBLP

Abstract

Algorithm development often involves a mix of disparate frameworks, leading to fragmented "glue code" that is difficult to maintain and prone to methodological errors like data leakage. We introduce tpcp (Tiny Pipelines for Complex Problems), a framework-agnostic Python library designed to standardize the construction and evaluation of complex algorithm pipelines. By providing unified interfaces for datasets, algorithms, and pipelines, tpcp enables researchers to integrate heuristics, machine learning, and deep learning into a single, robust workflow.

Introduction

In modern data science and algorithm research, practitioners frequently navigate a landscape of specialized libraries. While tools like scikit-learn offer excellent standardization for traditional machine learning, they can be overly restrictive for non-standard problems, such as multimodal time-series analysis or custom rule-based heuristics. Conversely, building custom frameworks from scratch often results in a proliferation of "glue code"—unstructured scripts for data loading, parameter tuning, and evaluation. This lack of formal structure increases the risk of implementation errors and hinders code reusability. tpcp addresses this "framework gap" by offering a set of high-level, object-oriented helpers that remain independent of any specific underlying computational framework.

Core Architecture and Methodology

The tpcp library is built around four primary abstractions that decouple data handling from algorithmic logic:

  1. tpcp.Dataset: Inspired by the modularity of PyTorch datasets, this class provides a common interface for diverse data sources, including local files and databases. It facilitates standardized iteration, filtering, and train-test splitting while encapsulating the underlying loading logic.
  2. tpcp.Algorithm: This base class enforces a consistent API—modeled after scikit-learn’s fit and predict paradigms—across different implementation backends. Whether an algorithm is built using TensorFlow, PyTorch, or pure Python, it adheres to a predictable interface.
  3. tpcp.Pipeline: The pipeline serves as the central orchestrator, defining the flow of data between Dataset and Algorithm objects for specific analysis tasks.
  4. Evaluation Tools: tpcp provides native implementations of robust evaluation schemes, such as cross_validate and GridSearch, specifically tailored for its object-oriented structure. It also includes integration with the Optuna optimization framework for hyperparameter tuning.
Figure 1: The tpcp architecture utilizes common interfaces to bridge datasets and algorithms within a unified pipeline.

Application Examples

The utility of tpcp is demonstrated through two complex real-world scenarios:

  • Sleep/Wake Detection: Researchers utilized tpcp to compare heuristic-based methods, traditional machine learning models, and deep learning architectures using multimodal wearable sensor data (cardiac and motion).
  • Stride Detection: The library facilitated the comparison of custom Hidden Markov Models (HMMs) against template-matching algorithms using IMU data collected from both laboratory and unsupervised home environments.

Discussion and Key Insights

The primary advantage of tpcp is its framework agnosticism. By not mandating a specific machine learning library, it allows researchers to select the optimal tool for each sub-task without sacrificing a unified evaluation framework. This separation of concerns makes code significantly more modular and reusable.

Furthermore, tpcp enhances methodological safety. By standardizing the "glue code" through built-in cross-validation and optimization tools, it helps prevent common pitfalls such as data leakage—where information from the test set inadvertently influences the training process. As projects grow in scope, tpcp scales effectively, managing complex interactions between multiple datasets and algorithmic pipelines.

Figure 2: tpcp scales to handle complex research scenarios involving multiple datasets, pipelines, and algorithm interfaces.

Conclusion and Future Work

tpcp provides a necessary bridge between rigid specialized libraries and unstructured custom scripts. While it introduces some initial implementation overhead and requires a solid grasp of object-oriented programming, the long-term benefits in code quality and research integrity are substantial. Future development will focus on expanding the library's documentation into a comprehensive repository of "recipes" for systematic algorithm development and evaluation.

Summary updated

BibTeX
@article{kuderle2023tpcp,
  author = {Arne Küderle and Robert Richer and Raul C. Sîmpetru and Bjoern M. Eskofier and Arne Küderle and Robert Richer and Bjoern Eskofier and Raul Sîmpetru},
  title = {{tpcp: Tiny Pipelines for Complex Problems - A set of framework independent helpers for algorithms development and evaluation}},
  journal = {J. Open Source Softw.},
  year = {2023},
  doi = {10.21105/joss.04953},
}
Figure