Skip to main content

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.

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 process
  • field_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 process
  • key_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