Standardize Task Cost Matrix #188
Copy link
Copy link
Open
Description
There is no standard or reasonable input validation for cost matrices right now. This leads to bad matrices such as “yes”, “adam”, or “1”.
We need to define what a valid cost matrix looks like, and add input validation for new tasks with cost matrices.
We might want to convert or delete old tasks with cost matrices (depending on how interpretable they are).
This might be most convenient to process when working on task 2.0, but can be done independently.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsWaiting
Activity
rohansen856 commentedon Nov 18, 2025
Hi @PGijsbers i would like to solve the issue with the following approach:
As i undestand, the Valid Cost Matrix Format is:
[]is allowed (represents no cost matrix)[](no cost matrix)[[0]](1x1 matrix)[[0, 1], [2, 0]](2x2 matrix)And in case of Invalid Formats:
[[0, 1], [2]][["a", "b"], ["c", "d"]]To solve this, we need to implement the following components:
1. Schema Validation (
src/schemas/tasks.py)CostMatrixPydantic model with strict validationvalidate_cost_matrix_input()function for database valuesTaskInputmodel with input-specific validation2. Runtime Validation (
src/routers/openml/tasks.py)[]3. Validation Utilities (
src/core/task_validation.py)validate_task_input()- extensible validation frameworkget_invalid_cost_matrices()- identify problematic entriesclean_invalid_cost_matrices()- automated cleanupAlso, one solution for processing the already present invalid formats:
A little Database Migration for:
Also implementing something like a
--checkflag (audit invalid cost matrices) or a--fixflag (automated cleanup of invalid entries) would be good in this case...So, In short,
For Existing Invalid Data:
For New Data:
I would like to work using the above implementation, solving the issue. Thanks!