How dssg/triage works
Main Components
• CLI & Entry Points: The primary user interaction is via the CLI (see manage.py and src/triage/cli.py). This command line interface is a key entry point where users initiate experiments.
• Experiment Runner: The “experiments” module within src/triage/experiments (for example, SingleThreadedExperiment, multicore, etc.) encapsulates the experiment execution logic.
• Modular Components: Triage is organized into multiple functional components found in src/triage/component. These include:
• Architect: Handles cohort selection, feature generation, labeling, and planning (e.g. in src/triage/component/architect).
• Audition: Manages scoring, model evaluation, thresholding, and rule generation.
• Catwalk: Provides baselines, model training, feature importance, and prediction utilities.
• Collate: Responsible for data aggregation and transformation routines.
• Postmodeling: Focuses on generating predictions, crosstabs, and fairness analysis.
• Results Schema: Manages database migrations and schema consistency with alembic.
• Timechop: Deals with temporal partitioning and visualization.
• Configuration Management: The system is highly configurable, using YAML files (such as database.yaml, experiment.yaml, and others in the example/config directory) to drive how the components behave.
• Data Storage and Database: Triage requires a PostgreSQL database to store source data, matrices, and experiment outputs. This dependency is evident in configuration files and database provisioning scripts (e.g. triage db up, Dockerfiles for the food_db subproject).
• Documentation and Tutorials: Although not part of the runtime, the extensive docs (in docs and example directories) explain usage, configuration, and tutorial examples (like the Dirty Duck tutorial).
Relationships and Interactions
• The user starts a Triage experiment via the CLI or by importing the package in a Python script.
• The CLI passes configuration information (from YAML files) to the Experiment Runner.
• The Experiment Runner orchestrates calls to various modular components:
• The Architect module generates data matrices (e.g., feature generation, label creation) and plans which features to build.
• Audition and Catwalk modules work on model training, evaluation, and generating performance metrics.
• Postmodeling takes the outputs, refines predictions, and generates reports (with fairness checks).
• The Results Schema ensures the underlying PostgreSQL database is structured correctly to persist experiment data.
• Timechop handles temporal aspects such as training/test splits and visualization of time-based trends.
• Each component interacts with a shared configuration and logging system (using src/triage/config) and accesses the database using a common set of utility functions.
• There is also a clear separation between “core experimental logic” and “infrastructure/data management” (with separate directories for configuration, experiments, and database reflection utilities).
Architectural Patterns and Design Principles
• Modularity: The architecture is broken into clearly defined components (architect, audition, catwalk, collate, etc.) that encapsulate specific steps in the ML workflow.
• Configurability: Heavy use of YAML configuration allows users to tailor experiments and run different data science pipelines without altering code.
• Reusability and Extensibility: The design encourages plugging in new algorithms or analysis routines by adding to the component modules.
• Integration with External Services: Triage supports running experiments locally or via cloud/Docker setups, evidenced by Dockerfiles and AWS batch examples.
• Robust Testing: The extensive “src/tests” directory shows that unit tests and integration tests are key, indicating a design that favors a tested, reliable structure.
Relevant Technologies, Frameworks, and Libraries
• Python 3.9+ (core language)
• PostgreSQL (for data storage)
• Docker/Docker Compose (for database provisioning and environment consistency)
• YAML (for configuration files)
• SQLAlchemy (for database engine creation and connection)
• Alembic (for database migrations within the results_schema component)
• PyTest (for testing)