Transformation functions¶
- giskard.transformation_function(_fn: Callable[[...], Series | DataFrame] | Type[TransformationFunction] | None = None, row_level=True, cell_level=False, name=None, tags: List[str] | None = None, needs_dataset=False)[source]¶
Decorator that registers a function as a transformation function and returns a TransformationFunction instance. It can be used for transforming datasets in a specific way during testing.
- Parameters:
_fn – function to decorate. No need to provide this argument, the decorator will automatically take as input the function to decorate.
name – Optional name to use for the function when registering it.
tags – Optional list of tags to use when registering the function.
row_level – Whether to apply the transformation function row-wise (default) or on the full dataframe. If row_level is True, the slicing function will receive a row (either a Series or DataFrame), and if False, it will receive the entire dataframe.
cell_level – Whether to apply the transformation function on the cell level. If True, the slicing function will be applied to individual cells instead of rows or the entire dataframe.
- Returns:
The wrapped function or a new instance of TransformationFunction.
- class giskard.registry.transformation_function.TransformationFunction(func: Callable[[...], Series | DataFrame] | None, row_level=True, cell_level=False, needs_dataset=False)[source]¶
Textual transformation functions¶
- giskard.functions.transformation.keyboard_typo_transformation(rate: SuiteInput | float | None = 0.1) TransformationFunction ¶
Generate a random typo from words of the text of ‘column_name’ Typos are generated through character substitution based on keyboard proximity
- giskard.functions.transformation.text_uppercase(column: SuiteInput | str | None = None) TransformationFunction ¶
- giskard.functions.transformation.text_lowercase(column: SuiteInput | str | None = None) TransformationFunction ¶
- giskard.functions.transformation.text_title_case(column: SuiteInput | str | None = None) TransformationFunction ¶
- giskard.functions.transformation.text_typo(column: SuiteInput | str | None = None, rate: SuiteInput | float | None = 0.05, min_length: SuiteInput | int | None = 10, rng_seed: SuiteInput | int | None = 1729) TransformationFunction ¶
- giskard.functions.transformation.text_typo_from_ocr(column: SuiteInput | str | None = None, rate: SuiteInput | float | None = 0.05, min_length: SuiteInput | int | None = 10, rng_seed: SuiteInput | int | None = 1729) TransformationFunction ¶
- giskard.functions.transformation.text_punctuation_removal(column: SuiteInput | str | None = None) TransformationFunction ¶
- giskard.functions.transformation.text_accent_removal(column: SuiteInput | str | None = None, rate: SuiteInput | float | None = 1.0, rng_seed: SuiteInput | int | None = 1729) TransformationFunction ¶
- giskard.functions.transformation.text_gender_switch(column: SuiteInput | str | None = None) TransformationFunction ¶
- giskard.functions.transformation.text_number_to_word(column: SuiteInput | str | None = None) TransformationFunction ¶
- giskard.functions.transformation.text_religion_switch(column: SuiteInput | str | None = None) TransformationFunction ¶
- giskard.functions.transformation.text_nationality_switch(column: SuiteInput | str | None = None) TransformationFunction ¶
- giskard.functions.transformation.text_typo_from_speech(column: SuiteInput | str | None = None, rng_seed: SuiteInput | int | None = 1729, min_length: SuiteInput | int | None = 10) TransformationFunction ¶
Special transformations used by the scan¶
- class giskard.scanner.robustness.text_transformations.TextAccentRemovalTransformation(column, rate=1.0, rng_seed=1729)[source]¶
Bases:
TextTransformation
- class giskard.scanner.robustness.text_transformations.TextFromOCRTypoTransformation(column, rate=0.05, min_length=10, rng_seed=1729)[source]¶
Bases:
TextTransformation
- class giskard.scanner.robustness.text_transformations.TextFromSpeechTypoTransformation(column, rng_seed=1729, min_length=10)[source]¶
- class giskard.scanner.robustness.text_transformations.TextGenderTransformation(column, rng_seed=1729)[source]¶
- class giskard.scanner.robustness.text_transformations.TextLanguageBasedTransformation(column, rng_seed=1729)[source]¶
Bases:
TextTransformation
- class giskard.scanner.robustness.text_transformations.TextLowercase(column, needs_dataset=False)[source]¶
Bases:
TextTransformation
- class giskard.scanner.robustness.text_transformations.TextNationalityTransformation(column, rng_seed=1729)[source]¶
- class giskard.scanner.robustness.text_transformations.TextNumberToWordTransformation(column, rng_seed=1729)[source]¶
- class giskard.scanner.robustness.text_transformations.TextPunctuationRemovalTransformation(*args, **kwargs)[source]¶
Bases:
TextTransformation
- class giskard.scanner.robustness.text_transformations.TextReligionTransformation(column, rng_seed=1729)[source]¶
- class giskard.scanner.robustness.text_transformations.TextTitleCase(column, needs_dataset=False)[source]¶
Bases:
TextTransformation
- class giskard.scanner.robustness.text_transformations.TextTransformation(column, needs_dataset=False)[source]¶
Bases:
TransformationFunction
- class giskard.scanner.robustness.text_transformations.TextTypoTransformation(column, rate=0.05, min_length=10, rng_seed=1729)[source]¶
Bases:
TextTransformation
- class giskard.scanner.robustness.text_transformations.TextUppercase(column, needs_dataset=False)[source]¶
Bases:
TextTransformation