bhepop2.enrichment.base

This module contains base code for synthetic population enrichment classes.

Module Contents

Classes

SyntheticPopulationEnrichment

This abstract class describes the base attributes and methods of

class bhepop2.enrichment.base.SyntheticPopulationEnrichment(population: pandas.DataFrame, source, feature_name: str = None, seed=None)

Bases: abc.ABC, bhepop2.utils.Bhepop2Logger

This abstract class describes the base attributes and methods of synthetic population enrichment classes.

The class instances work on an original synthetic population, which is enriched using a dedicated algorithm.

This enrichment process is executed in the assign_feature_value_to_pop method. Its implementation, and the algorithm used to evaluate the feature values, are core to the SyntheticPopulationEnrichment classes.

assign_feature_values()

Assign feature values to the population individuals.

This method evaluates and adds feature values to each population individual. The name of the added column is defined by the feature_name class parameter.

Returned enriched population is a copy of the original population. The original population is not modified.

Returns:

enriched population

abstract _evaluate_feature_on_population()

Evaluate a list of feature values for each individual.

Returns:

iterable with same size and order than the population

_get_value_for_feature(feature_id)

Get a feature value for the given feature id.

This method is a helper that class self.source.get_value_for_feature with feature id and self.rng.

Parameters:

feature_id

Returns:

feature value

abstract _validate_and_process_inputs()

Validate and process the provided enrichment inputs.

Both the population and the enrichment source may need to be validated.

Raise:

ValueError if validation fails

compare_with_source(enriched_population_name: str = 'enriched_population', **kwargs)

Create a PopulationAnalysis instance for the enriched population.

Parameters:
  • enriched_population_name – display name of the enriched population

  • kwargs – additional parameters for the PopulationAnalysis instantiation

Returns:

PopulationAnalysis for the current enriched population