Combinations

Combinations are at the core of Carvers. They are used to identify the best combination from all possible combinations with up to max_n_mod modalities.

A pre-built CombinationEvaluator instance can be passed to any carver via the combination_evaluator keyword. Each subclass defaults to a task-appropriate metric: TschuprowtCombinations for BinaryCarver / MulticlassCarver, KruskalCombinations for ContinuousCarver.

class AutoCarver.combinations.CombinationEvaluator(*, verbose: bool = False, target_rate: TargetRate | None = None)

CombinationEvaluator class to evaluate the best combination of modalities for a feature.

Parameters:
  • verbose (bool, optional) – Whether to print progress / statistics, by default False.

  • target_rate (TargetRate, optional) – Target rate strategy. If None, each evaluator subclass picks its own default in _init_target_rate().

get_best_combination(feature: BaseFeature, xagg: Series | DataFrame | None, xagg_dev: Series | DataFrame | None = None, *, max_n_mod: int, min_freq: float, dropna: bool) dict | None

Computes best combination of modalities for the feature

classmethod load(file: str | dict) CombinationEvaluator

Allows one to load a CombinationEvaluator saved as a .json file.

Parameters:

file (str | dict) – String of .json file name or content of the file.

Returns:

A ready-to-use CombinationEvaluator

Return type:

CombinationEvaluator

save(file_name: str) None

Saves CombinationEvaluator to .json file.

Parameters:

file_name (str) – String of .json file name

Classification tasks

Cramér’s V Combinations

See Cramér’s V for more details on the metric.

class AutoCarver.combinations.CramervCombinations(*, verbose: bool = False, target_rate: TargetRate | None = None)

Cramér’s V based combination evaluation toolkit

Parameters:
  • verbose (bool, optional) – Whether to print progress / statistics, by default False.

  • target_rate (TargetRate, optional) – Target rate strategy. If None, each evaluator subclass picks its own default in _init_target_rate().

classmethod load(file: str | dict) CombinationEvaluator

Allows one to load a CombinationEvaluator saved as a .json file.

Parameters:

file (str | dict) – String of .json file name or content of the file.

Returns:

A ready-to-use CombinationEvaluator

Return type:

CombinationEvaluator

save(file_name: str) None

Saves CombinationEvaluator to .json file.

Parameters:

file_name (str) – String of .json file name

Tschuprow’s T Combinations

See Tschuprow’s T for more details on the metric.

class AutoCarver.combinations.TschuprowtCombinations(*, verbose: bool = False, target_rate: TargetRate | None = None)

Tschuprow’s T based combination evaluation toolkit

Parameters:
  • verbose (bool, optional) – Whether to print progress / statistics, by default False.

  • target_rate (TargetRate, optional) – Target rate strategy. If None, each evaluator subclass picks its own default in _init_target_rate().

classmethod load(file: str | dict) CombinationEvaluator

Allows one to load a CombinationEvaluator saved as a .json file.

Parameters:

file (str | dict) – String of .json file name or content of the file.

Returns:

A ready-to-use CombinationEvaluator

Return type:

CombinationEvaluator

save(file_name: str) None

Saves CombinationEvaluator to .json file.

Parameters:

file_name (str) – String of .json file name

Regression tasks

Kruskal’s H Combinations

See Kruskal-Wallis’ H test statistic for more details on the metric.

class AutoCarver.combinations.KruskalCombinations(*, verbose: bool = False, target_rate: TargetRate | None = None)

Kruskal-Wallis’ H based combination evaluation toolkit

Parameters:
  • verbose (bool, optional) – Whether to print progress / statistics, by default False.

  • target_rate (TargetRate, optional) – Target rate strategy. If None, each evaluator subclass picks its own default in _init_target_rate().

classmethod load(file: str | dict) CombinationEvaluator

Allows one to load a CombinationEvaluator saved as a .json file.

Parameters:

file (str | dict) – String of .json file name or content of the file.

Returns:

A ready-to-use CombinationEvaluator

Return type:

CombinationEvaluator

save(file_name: str) None

Saves CombinationEvaluator to .json file.

Parameters:

file_name (str) – String of .json file name