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
- Generic types
~T_SupervisedLearnerDF(bound=
SupervisedLearnerDF
)- Metaclasses
- Parameters
model (
BaseUnivariateSimulator
) – a fitted learner to use for calculating simulated outputssample (
Sample
) – the sample to be used for baseline calculations and simulationsconfidence_level (
float
) – the width \(\alpha\) of the confidence interval to be estimated for simulation resultsn_jobs (
Optional
[int
]) – number of jobs to use in parallel; ifNone
, use joblib default (default:None
)shared_memory (
Optional
[bool
]) – ifTrue
, use threads in the parallel runs; ifFalse
orNone
, use multiprocessing (default:None
)pre_dispatch (
Union
[int
,str
,None
]) – number of batches to pre-dispatch; ifNone
, use joblib default (default:None
)verbose (
Optional
[int
]) – verbosity level used in the parallel computation; ifNone
, use joblib default (default:None
)
Method summary
Calculate the expectation value of the simulation result, based on historically observed actuals.
Calculate the expectation value of the actual model output, based on historically observed actuals.
Simulate the average target uplift when fixing the value of the given feature across all observations.
Attribute summary
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; ifFalse
orNone
, 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.The learner pipeline used to conduct simulations
The sample to be used in baseline calculations and simulations
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
- 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
- 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 forpartitioner (
Partitioner
[TypeVar
(T_Value
, bound=generic
)]) – the partitioner of feature values to run simulations forpartitioner_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
- sample: facet.data.Sample#
The sample to be used in baseline calculations and simulations