bhepop2.sources.base
This module contains the abstract classes describing an enrichment source.
Module Contents
Classes
EnrichmentSource classes are supposed to provide ways |
|
Class containing additional arguments used by quantitative sources. |
Attributes
- bhepop2.sources.base.DEFAULT_SOURCE_NAME = 'Enrichment source'
- class bhepop2.sources.base.EnrichmentSource(data, name: str = None)
Bases:
abc.ABC
,bhepop2.utils.Bhepop2Logger
EnrichmentSource classes are supposed to provide ways to enrich or analyze a population.
Sources describe a specific feature, for instance declared income.
- property feature_values
- property nb_feature_values
- abstract _evaluate_feature_values()
Evaluate the values that can be taken by the described feature.
The result will be stored in the feature_values property.
- Returns:
object describing the feature values
- abstract _validate_data()
Validate the source data.
Raise a ValueError if data is invalid.
- Raises:
SourceValidationError
- usable_with_population(population)
Validate that this source is compatible with the given population.
Raise a PopulationValidationError if an incompatibility is found.
- Parameters:
population – population DataFrame
- Raises:
- abstract get_value_for_feature(feature_index, rng)
Return a feature value for the given feature index.
Generate a singular value from the feature state corresponding to the given index.
- Parameters:
feature_index – index of the feature in self.feature_values
rng – Numpy random Generator
- Returns:
feature value
- abstract compare_with_populations(populations, feature_name, **kwargs)
Compare the source data with populations containing the described feature (enriched or original)
The class returns an instance of a PopulationAnalysis subclass, which can be used to generate different kinds of comparisons between the populations and the source data.
- Parameters:
populations – dict of populations {population_name: population}
feature_name – population column containing the feature values
kwargs – additional arguments for the analysis instance
- Returns:
PopulationAnalysis subclass instance.