facet.simulation.base.BaseUnivariateSimulator#

class facet.simulation.base.BaseUnivariateSimulator(model, sample, *, confidence_level=0.95, n_jobs=None, shared_memory=None, pre_dispatch=None, verbose=None)[source]#

Base class for univariate simulations.

Bases

ParallelizableMixin

Generic types

~T_SupervisedLearnerDF(bound= SupervisedLearnerDF)

Metaclasses

ABCMeta

Parameters
  • model (BaseUnivariateSimulator) – a fitted learner to use for calculating simulated outputs

  • sample (Sample) – the sample to be used for baseline calculations and simulations

  • confidence_level (float) – the width \(\alpha\) of the confidence interval to be estimated for simulation results

  • n_jobs (Optional[int]) – number of jobs to use in parallel; if None, use joblib default (default: None)

  • shared_memory (Optional[bool]) – if True, use threads in the parallel runs; if False or None, use multiprocessing (default: None)

  • pre_dispatch (Union[int, str, None]) – number of batches to pre-dispatch; if None, use joblib default (default: None)

  • verbose (Optional[int]) – verbosity level used in the parallel computation; if None, use joblib default (default: None)

Method summary

baseline

Calculate the expectation value of the simulation result, based on historically observed actuals.

expected_output

Calculate the expectation value of the actual model output, based on historically observed actuals.

simulate_feature

Simulate the average target uplift when fixing the value of the given feature across all observations.

Attribute summary

output_unit

Unit of the output values calculated by the simulation.

n_jobs

Number of jobs to use in parallel; if None, use joblib default.

shared_memory

If True, use threads in the parallel runs; if False or None, use multiprocessing.

pre_dispatch

Number of batches to pre-dispatch; if None, use joblib default.

verbose

Verbosity level used in the parallel computation; if None, use joblib default.

model

The learner pipeline used to conduct simulations

sample

The sample to be used in baseline calculations and simulations

confidence_level

The width of the confidence interval used to calculate the lower/upper bound of the simulation

Definitions

baseline()[source]#

Calculate the expectation value of the simulation result, based on historically observed actuals.

Return type

float

Returns

the expectation value of the simulation results

abstract expected_output()[source]#

Calculate the expectation value of the actual model output, based on historically observed actuals.

Return type

float

Returns

the expectation value of the actual model output

simulate_feature(feature_name, *, partitioner, **partitioner_params)[source]#

Simulate the average target uplift when fixing the value of the given feature across all observations.

Simulations are run for a set of values determined by the given partitioner, which is fitted to the observed values for the feature being simulated.

Parameters
  • feature_name (str) – the feature to run the simulation for

  • partitioner (Partitioner[TypeVar(T_Value, bound= generic)]) – the partitioner of feature values to run simulations for

  • partitioner_params (Any) – additional parameters to pass to the partitioner

Return type

UnivariateSimulationResult[TypeVar(T_Value, bound= generic)]

Returns

a mapping of output names to simulation results

confidence_level: float#

The width of the confidence interval used to calculate the lower/upper bound of the simulation

model: T_SupervisedLearnerDF#

The learner pipeline used to conduct simulations

abstract property output_unit: str#

Unit of the output values calculated by the simulation.

Return type

str

sample: facet.data.Sample#

The sample to be used in baseline calculations and simulations