Skip to main content

post_processing_base

Base classes and utilities for post-processors.

Module

Functions

apply_postprocessors

def apply_postprocessors(postprocessors: list[PostProcessor], predictions: Any)> Any:

Apply a list of postprocessors to predictions in sequence.

Arguments

  • postprocessors: List of postprocessors to apply.
  • predictions: Model predictions to process.

Returns Processed predictions

create_postprocessor

def create_postprocessor(    config: dict[str, Any], access_token: Optional[str] = None,)> Optional[PostProcessor]:

Create a postprocessor from a configuration dictionary.

Arguments

  • config: Postprocessor configuration with 'type' and other parameters
  • access_token: An optional HuggingFace access token

Returns An instance of the requested postprocessor or None if there is an error when creating it.

create_postprocessors

def create_postprocessors(    postprocessor_configs: Optional[list[dict[str, Any]]] = None,    access_token: Optional[str] = None,)> list[PostProcessor]:

Create a list of postprocessors from configurations.

Arguments

  • postprocessor_configs: Configuration for postprocessors, either: - None (returns an empty list) - A list of dicts, each with 'type' and other parameters
  • access_token: An optional HuggingFace access token

Returns List of PostProcessors.

get_matching_columns

def get_matching_columns(all_columns: list[str], patterns: list[str])> list[str]:

Get column names matching the given patterns.

Arguments

  • all_columns: List of all column names.
  • patterns: List of regex patterns to match.

Returns List of column names that match at least one pattern.

parse_json

def parse_json(value: Any)> Any:

Parse JSON data from various formats.

Arguments

  • value: The value to parse.

Returns Parsed JSON object or original value if parsing fails.

Classes

CompoundPostProcessor

class CompoundPostProcessor(    postprocessing_sequence: list[dict[str, Any]], name: Optional[str] = None,):

Applies multiple postprocessors in sequence.

Initialize the compound postprocessor.

Arguments

  • postprocessing_sequence: List of postprocessor configurations to apply in a sequence
  • name: Name as a string for the for this transformation pipeline. Default to None.

Ancestors

Methods


process

def process(self, predictions: Any)> Any:

Apply all postprocessors in sequence.

PostProcessor

class PostProcessor():

Base class that all postprocessors inherit from.

Methods


process

def process(    self, predictions: Union[PredictReturnType, pd.DataFrame],)> Union[PredictReturnType, pandas.core.frame.DataFrame, Any]:

Process the model predictions.

PostprocessorType

class PostprocessorType(*args, **kwds):

Types of built-in postprocessors.

Ancestors

Variables

  • static COMPOUND
  • static HUGGINGFACE_APPLY_ID_TO_LABELS
  • static JSON_KEY_RENAME
  • static JSON_RESTRUCTURE
  • static JSON_WRAP_IN_LIST
  • static NER_DEIDENTIFICATION
  • static RENAME
  • static STRING_TO_JSON
  • static TRANSFORM