View source on GitHub
|
Meridian EDA Engine.
meridian.model.eda.eda_engine.EDAEngine(
meridian: (model.Meridian | None) = None,
spec: eda_spec.EDASpec = eda_spec.EDASpec(),
*,
model_context: (context.ModelContext | None) = None
)
Methods
check_cost_per_media_unit
check_cost_per_media_unit() -> eda_outcome.EDAOutcome[eda_outcome.CostPerMediaUnitArtifact]
Checks if the cost per media unit is valid.
This function checks the following conditions: 1. cost == 0 and media unit > 0. 2. cost > 0 and media unit == 0. 3. cost_per_media_unit has outliers.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
check_geo_cost_per_media_unit
check_geo_cost_per_media_unit() -> eda_outcome.EDAOutcome[eda_outcome.CostPerMediaUnitArtifact]
Checks if the cost per media unit is valid for geo data.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
| Raises | |
|---|---|
GeoLevelCheckOnNationalModelError
|
If the check is called for a national model. |
check_geo_pairwise_corr
check_geo_pairwise_corr() -> eda_outcome.EDAOutcome[eda_outcome.PairwiseCorrArtifact]
Checks pairwise correlation among treatments and controls for geo data.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
| Raises | |
|---|---|
GeoLevelCheckOnNationalModelError
|
If the model is national. |
check_geo_std
check_geo_std() -> eda_outcome.EDAOutcome[eda_outcome.StandardDeviationArtifact]
Checks std for geo-level KPI, treatments, R&F, and controls.
check_geo_vif
check_geo_vif() -> eda_outcome.EDAOutcome[eda_outcome.VIFArtifact]
Checks geo variance inflation factor among treatments and controls.
The VIF calculation only focuses on multicollinearity among non-constant variables. Any variable with constant values will result in a NaN VIF value.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
check_national_cost_per_media_unit
check_national_cost_per_media_unit() -> eda_outcome.EDAOutcome[eda_outcome.CostPerMediaUnitArtifact]
Checks if the cost per media unit is valid for national data.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
check_national_pairwise_corr
check_national_pairwise_corr() -> eda_outcome.EDAOutcome[eda_outcome.PairwiseCorrArtifact]
Checks pairwise correlation among treatments and controls for national data.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
check_national_std
check_national_std() -> eda_outcome.EDAOutcome[eda_outcome.StandardDeviationArtifact]
Checks std for national-level KPI, treatments, R&F, and controls.
check_national_vif
check_national_vif() -> eda_outcome.EDAOutcome[eda_outcome.VIFArtifact]
Checks national variance inflation factor among treatments and controls.
The VIF calculation only focuses on multicollinearity among non-constant variables. Any variable with constant values will result in a NaN VIF value.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
check_overall_kpi_invariability
check_overall_kpi_invariability() -> eda_outcome.EDAOutcome[eda_outcome.KpiInvariabilityArtifact]
Checks if the KPI is constant across all geos and times.
check_pairwise_corr
check_pairwise_corr() -> eda_outcome.EDAOutcome[eda_outcome.PairwiseCorrArtifact]
Checks pairwise correlation among treatments and controls.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
check_population_corr_raw_media
check_population_corr_raw_media() -> eda_outcome.EDAOutcome[eda_outcome.PopulationCorrelationArtifact]
Checks Spearman correlation between population and raw media executions.
Calculates correlation between population and time-averaged raw media executions (paid/organic impressions/reach). These are expected to have reasonably high correlation with population.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
| Raises | |
|---|---|
GeoLevelCheckOnNationalModelError
|
If the model is national or geo population data is missing. |
check_population_corr_scaled_treatment_control
check_population_corr_scaled_treatment_control() -> eda_outcome.EDAOutcome[eda_outcome.PopulationCorrelationArtifact]
Checks Spearman correlation between population and treatments/controls.
Calculates correlation between population and time-averaged treatments and controls. High correlation for controls or non-media channels may indicate a need for population-scaling. High correlation for other media channels may indicate double-scaling.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
| Raises | |
|---|---|
GeoLevelCheckOnNationalModelError
|
If the model is national or geo population data is missing. |
check_std
check_std() -> eda_outcome.EDAOutcome[eda_outcome.StandardDeviationArtifact]
Checks standard deviation for treatments and controls.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
check_variable_geo_time_collinearity
check_variable_geo_time_collinearity() -> eda_outcome.EDAOutcome[eda_outcome.VariableGeoTimeCollinearityArtifact]
Compute adjusted R-squared for treatments and controls vs geo and time.
These checks are applied to geo-level dataset only.
| Returns | |
|---|---|
| An EDAOutcome object containing a VariableGeoTimeCollinearityArtifact. The artifact includes a Dataset with 'rsquared_geo' and 'rsquared_time', showing the adjusted R-squared values for each treatment/control variable when regressed against 'geo' and 'time', respectively. If a variable is constant across geos or times, the corresponding 'rsquared_geo' or 'rsquared_time' value will be NaN. |
check_vif
check_vif() -> eda_outcome.EDAOutcome[eda_outcome.VIFArtifact]
Computes variance inflation factor among treatments and controls.
The VIF calculation only focuses on multicollinearity among non-constant variables. Any variable with constant values will result in a NaN VIF value.
| Returns | |
|---|---|
| An EDAOutcome object with findings and result values. |
run_all_critical_checks
run_all_critical_checks() -> eda_outcome.CriticalCheckEDAOutcomes
Runs all critical EDA checks.
Critical checks are those that can result in EDASeverity.ERROR findings.
| Returns | |
|---|---|
| A CriticalCheckEDAOutcomes object containing the results of all critical checks. |
View source on GitHub