示例#1
0
 def __init__(self, cause, risk):
     self.cause = EntityString(cause)
     self.risk = EntityString(risk)
     self.state_column = self.cause.name
     self.state_id = self.cause.name
     self.diseased_event_time_column = f'{self.cause.name}_event_time'
     self.susceptible_event_time_column = f'susceptible_to_{self.cause.name}_event_time'
     self.configuration_defaults = {
         self.cause.name: RiskAttributableDisease.configuration_defaults['risk_attributable_disease']
     }
示例#2
0
    def setup(self, builder):
        self.risk = EntityString(
            f'risk_factor.{project_globals.LBWSG_MODEL_NAME}')
        self.exposure_distribution = LBWSGDistribution(builder)

        # FIXME: These are not actual birth weights/gestational times, but the
        # raw values that source pipelines.  They should use different column
        # names but that's too much to try to fix now.  We didn't build the
        # distribution class with clear enough boundaries to make the
        # distinction.
        created_columns = project_globals.LBWSG_COLUMNS
        self.population_view = builder.population.get_view(created_columns +
                                                           ['tracked'])
        builder.population.initializes_simulants(
            self.on_initialize_simulants,
            creates_columns=created_columns,
            requires_columns=['age', 'sex'])

        self._raw_exposure = builder.value.register_value_producer(
            f'{self.risk.name}.raw_exposure',
            source=lambda index: self.population_view.get(index),
            requires_columns=project_globals.LBWSG_COLUMNS)
        self.exposure = builder.value.register_value_producer(
            f'{self.risk.name}.exposure',
            source=self._raw_exposure,
            preferred_post_processor=self.exposure_distribution.
            convert_to_categorical,
            requires_values=f'{self.risk.name}.raw_exposure')
示例#3
0
 def __init__(self, risk: str):
     """
     Parameters
     ----------
     risk :
         the type and name of a risk, specified as "type.name". Type is singular.
     """
     self.risk = EntityString(risk)
     self.configuration_defaults = {f'{self.risk.name}': Risk.configuration_defaults['risk']}
     self.exposure_distribution = SimulationDistribution(self.risk)
     self._sub_components = [self.exposure_distribution]
示例#4
0
 def __init__(self, target: str):
     """
     Parameters
     ----------
     target :
         Type, name, and target rate of entity to be affected by risk factor,
         supplied in the form "entity_type.entity_name.measure"
         where entity_type should be singular (e.g., cause instead of causes).
     """
     self.risk = EntityString(
         f'risk_factor.low_birth_weight_and_short_gestation')
     self.target = TargetString(target)
    def __init__(self, builder):
        self.risk = EntityString(
            'risk_factor.low_birth_weight_and_short_gestation')
        self.randomness = builder.randomness.get_stream(
            f'{self.risk.name}.exposure')

        self.categories_by_interval = get_categories_by_interval(
            builder, self.risk)
        self.intervals_by_category = self.categories_by_interval.reset_index(
        ).set_index('cat')
        self.max_gt_by_bw, self.max_bw_by_gt = self._get_boundary_mappings()

        self.exposure_parameters = builder.lookup.build_table(
            get_exposure_data(builder, self.risk))
示例#6
0
    def __init__(self, risk: str):
        """
        Parameters
        ----------
        risk :
        the type and name of a risk, specified as "type.name". Type is singular.

        """
        self.risk = EntityString(risk)
        self.configuration_defaults = {
            'metrics': {
                f'{self.risk.name}_observer':
                RiskObserver.configuration_defaults['metrics']['risk_observer']
            }
        }
示例#7
0
    def __init__(self, builder):
        self.risk = EntityString(
            f'risk_factor.{project_globals.LBWSG_MODEL_NAME}')
        self.randomness = builder.randomness.get_stream(
            f'{self.risk.name}.exposure')

        self.categories_by_interval = get_lbwsg_categories_by_interval(builder)
        self.intervals_by_category = self.categories_by_interval.reset_index(
        ).set_index('cat')
        self.max_gt_by_bw, self.max_bw_by_gt = self._get_boundary_mappings()

        self.exposure_parameters = builder.lookup.build_table(
            self.get_exposure_data(builder),
            key_columns=['sex'],
            parameter_columns=['age', 'year'])
 def __init__(self, target: str):
     """
     Parameters
     ----------
     target :
         Type, name, and target rate of entity to be affected by risk factor,
         supplied in the form "entity_type.entity_name.measure"
         where entity_type should be singular (e.g., cause instead of causes).
     """
     self.risk = EntityString(
         'risk_factor.low_birth_weight_and_short_gestation')
     self.target = TargetString(target)
     self.configuration_defaults = {
         f'effect_of_{self.risk.name}_on_{self.target.name}': {
             self.target.measure:
             RiskEffect.configuration_defaults['effect_of_risk_on_target']
             ['measure']
         }
     }
 def __init__(self, risk: str, target: str):
     """
     Parameters
     ----------
     risk :
         Type and name of risk factor, supplied in the form
         "risk_type.risk_name" where risk_type should be singular (e.g.,
         risk_factor instead of risk_factors).
     target :
         Type, name, and target rate of entity to be affected by risk factor,
         supplied in the form "entity_type.entity_name.measure"
         where entity_type should be singular (e.g., cause instead of causes).
     """
     self.risk = EntityString(risk)
     self.target = TargetString(target)
     self.configuration_defaults = {
         f'effect_of_{self.risk.name}_on_{self.target.name}': {
             self.target.measure: RiskEffect.configuration_defaults['effect_of_risk_on_target']['measure']
         }
     }
示例#10
0
 def __init__(self, risk, low, high):
     self.risk = EntityString(risk)
     self.low = int(low)
     self.high = int(high)
     self.exp = pd.Series()
 def __init__(self):
     self.risk = EntityString(
         'risk_factor.low_birth_weight_and_short_gestation')
示例#12
0
def test_EntityString_pass(s):
    entity_type, entity_name = s.split('.')
    r = EntityString(s)
    assert r.type == entity_type
    assert r.name == entity_name
示例#13
0
def test_EntityString_fail(s):
    with pytest.raises(ValueError):
        EntityString(s)