post_processing
Utilities for post-processing.
Classes
ColumnRenamerPostProcessor
class ColumnRenamerPostProcessor(column_mapping: dict[str, str]):Renames columns in a DataFrame.
Initialize the column renamer.
Arguments
column_mapping: Mapping from old column names to new column names.
Ancestors
Methods
process
def process(self, predictions: Any) ‑> Any:Process the predictions by renaming columns.
Arguments
predictions: The model output to process.
Returns Processed predictions with renamed columns.
JSONExtractToColumnsPostProcessor
class JSONExtractToColumnsPostProcessor( source_column: str, extractions: list[dict[str, Any]] | None = None, drop_source: bool = True,):Extracts fields from a JSON dict column into new DataFrame columns.
Uses dot-notation paths with support for integer array indexing.
Extraction configs are provided as a list of dicts, each with:
target_column– name of the new DataFrame column to createsource_path– dot-notation path to extract a value from the JSON dict (e.g."exam_center_slice_index.0"). Supports integer indices for list access.
Initialise the JSON extract-to-columns postprocessor.
Arguments
source_column: Name of the column containing the parsed JSON dict.extractions: List of extraction configs. Each must havetarget_columnandsource_path.drop_source: Whether to drop the source column after extraction.
Ancestors
Methods
process
def process(self, predictions: Any) ‑> Any:Extract fields from JSON dicts into new columns.
JSONFieldRestructuringPostProcessor
class JSONFieldRestructuringPostProcessor( column_patterns: list[str], field_mappings: list[dict[str, str]], keep_original: bool = False,):Restructures JSON data by moving fields between different levels.
This is done for example to move fields from one json
level to another as for example from
{"key1": {"key2": "value", "key3": "val"}} to
{"key1": {"key2": "value"}, "key3": "val"} and vice-versa.
Initialize the JSON field restructurer.
Arguments
column_patterns: List of regex patterns matching columns to processfield_mappings: List of mappings, each with:- 'source_path': JSON path to extract (using dot notation, e.g., 'key1.key2' or 'key2')
- 'target_path': Path to place the value (dot notation, e.g., ''key1.key2' or 'key2'')
keep_original: Whether to keep the original fields
Ancestors
Methods
process
def process(self, predictions: Any) ‑> Any:Process predictions by restructuring JSON fields.
JSONKeyRenamerPostProcessor
class JSONKeyRenamerPostProcessor( column_patterns: list[str], key_mappings: list[dict[str, str]], recursive: bool = True,):Renames keys within JSON data stored in columns.
Initialize the JSON key renamer.
Arguments
column_patterns: List of regex patterns matching columns to processkey_mappings: List of mappings, each with:- 'source_key': Original key name
- 'target_key': New key name
recursive: Whether to rename keys recursively throughout nested objects
Ancestors
Methods
process
def process(self, predictions: Any) ‑> Any:Process predictions by renaming JSON keys.
JSONWrapInListPostProcessor
class JSONWrapInListPostProcessor(column_patterns: list[str]):Wraps JSON data in an additional list layer.
Initialize the JSON wrap in list processor.
Arguments
column_patterns: List of regex patterns matching columns to process
Ancestors
Methods
process
def process(self, predictions: Any) ‑> Any:Process predictions by wrapping JSON data in an additional list.
StringToJSONPostProcessor
class StringToJSONPostProcessor(column_patterns: list[str]):Converts string columns containing JSON data to actual JSON/dict objects.
Initialize the string to JSON converter.
Arguments
column_patterns: List of regex patterns matching column names to process
Ancestors
Methods
process
def process(self, predictions: Any) ‑> Any:Process predictions by converting string columns to JSON objects.
TransformationApplierPostProcessor
class TransformationApplierPostProcessor( transformations: Union[list[Transformation], list[dict[str, Any]]],):Applies transformations from the transformations module.
Initialize the transformation applier.
Arguments
transformations: List of transformations to apply. Can be either:- A list of Transformation objects (for programmatic use)
- A list of dicts (from YAML config) that will be parsed into Transformation objects
Ancestors
Methods
process
def process(self, predictions: Any) ‑> Any:Process the predictions using the transformations.
Arguments
predictions: Model output to process
Returns Processed predictions
ZipFlattenCoordinatesPostProcessor
class ZipFlattenCoordinatesPostProcessor( source_column: str, target_column: str, slice_indices_path: str, coordinates_path: str, drop_source: bool = False,):Zips slice indices with per-slice coordinate groups and flattens.
Reads a dict from a source column, extracts two parallel arrays
(slice indices and coordinate groups), and produces a flat list of
[slice_idx, coord_0, coord_1] triples written to a target column.
Each coordinate pair is prepended with its corresponding slice index and written as-is (no reordering).
Initialise the zip-flatten-coordinates postprocessor.
Arguments
source_column: Column containing the parsed dict.target_column: Name of the output column for the flattened coordinate triples.slice_indices_path: Dot-notation path to the slice indices array within the dict.coordinates_path: Dot-notation path to the per-slice coordinate groups array within the dict.drop_source: Whether to drop the source column after processing.
Ancestors
Methods
process
def process(self, predictions: Any) ‑> Any:Zip-flatten coordinates from JSON dicts into a new column.