Skip to content
Increment 0.1.0a6 prerelease documentation. These docs describe the increment 0.1.0a6 prerelease (v0.1.0a6). Its API may change. Install: pip install 'increment==0.1.0a6' Keep any extras requested by the guide, such as increment[dashboard]==0.1.0a6.

Dataframe entry points

MetricSpec

One metric to estimate from a dataframe column.

name : str Metric name, and the value column unless value_column is given. value_column : str | None Read metric values from this column instead of name. type : {“mean”, “conversion”, “ratio”, “retention”, “quantile”} Dispatches the variance model: “conversion” is a 0/1 column, “quantile” needs quantile, “retention” needs threshold_days. winsorization : Winsorization | None Optional lower/upper outcome bounds for a mean metric. numerator, denominator : str | None Ratio-metric columns; both required when type="ratio". window_days : int | None Analysis window in days since exposure; None uses full history. Rejected on type="quantile". threshold_days : int | tuple[int, int] | None Retention band: int N is [N, inf); (a, b) is [a, b) (half-open). quantile : float | None The quantile in (0, 1) to estimate; required for type="quantile". missing : {“error”, “zero”, “skip”} Null/NaN policy for the value column: refuse (default), count as 0, or skip those units in this metric only; a skipped metric’s rows state the observed population. "impute" is refused (frame.metric.missing_impute): an outcome is never mean-filled. "drop" is refused (frame.metric.missing_drop_renamed); it is now "skip". decision_method : Method | None Decision estimator for this metric. Omitted uses IPTW for an observational design, otherwise unadjusted. A call-time run(decision_method=...) takes precedence for that run; if it replaces this declared value, run() warns. sensitivity_methods : tuple[Method, …] Additional estimators reported after the decision estimator. Each CUPED method owns its covariate declarations and missing policy. A call-time run(sensitivity_methods=...) replaces this list for that run; if it replaces a non-empty declaration, run() warns. prior : Normal | RelativeLiftPrior | None Informative prior for this metric’s rows. Omitted uses no declared prior. A call-time run(prior=...) takes precedence for that run; if it replaces this prior, run() warns. preferred_direction : {“increase”, “decrease”, “neutral”} | None The metric’s declared favorable side; None (default) means undeclared, not “increase” — synthesise_metric forwards it onto the synthesised Metric only when explicitly set, so an undeclared frame metric never silently reports a favorable direction (see LiftEstimate.preferred_direction). Notes

Section titled “name : str Metric name, and the value column unless value_column is given. value_column : str | None Read metric values from this column instead of name. type : {“mean”, “conversion”, “ratio”, “retention”, “quantile”} Dispatches the variance model: “conversion” is a 0/1 column, “quantile” needs quantile, “retention” needs threshold_days. winsorization : Winsorization | None Optional lower/upper outcome bounds for a mean metric. numerator, denominator : str | None Ratio-metric columns; both required when type="ratio". window_days : int | None Analysis window in days since exposure; None uses full history. Rejected on type="quantile". threshold_days : int | tuple[int, int] | None Retention band: int N is [N, inf); (a, b) is [a, b) (half-open). quantile : float | None The quantile in (0, 1) to estimate; required for type="quantile". missing : {“error”, “zero”, “skip”} Null/NaN policy for the value column: refuse (default), count as 0, or skip those units in this metric only; a skipped metric’s rows state the observed population. "impute" is refused (frame.metric.missing_impute): an outcome is never mean-filled. "drop" is refused (frame.metric.missing_drop_renamed); it is now "skip". decision_method : Method | None Decision estimator for this metric. Omitted uses IPTW for an observational design, otherwise unadjusted. A call-time run(decision_method=...) takes precedence for that run; if it replaces this declared value, run() warns. sensitivity_methods : tuple[Method, …] Additional estimators reported after the decision estimator. Each CUPED method owns its covariate declarations and missing policy. A call-time run(sensitivity_methods=...) replaces this list for that run; if it replaces a non-empty declaration, run() warns. prior : Normal | RelativeLiftPrior | None Informative prior for this metric’s rows. Omitted uses no declared prior. A call-time run(prior=...) takes precedence for that run; if it replaces this prior, run() warns. preferred_direction : {“increase”, “decrease”, “neutral”} | None The metric’s declared favorable side; None (default) means undeclared, not “increase” — synthesise_metric forwards it onto the synthesised Metric only when explicitly set, so an undeclared frame metric never silently reports a favorable direction (see LiftEstimate.preferred_direction). Notes”

window_days/threshold_days are validated here, at construction, with the models layer’s own refusals (definition.retention.*, definition.models.reject_bool): a retention band that is empty or negative, or window_days on a retention spec, never constructs. from_unit_summary carries no dates, so it refuses both instead (see CAPABILITY_TABLE).

to_frame(estimates, model, backend, columns)

Convert a sequence of result models (:class:LiftEstimate, :class:BreakoutEstimate, :class:DailyMetricValue, :class:DailyLiftEstimate) to a native backend frame.

Generic over pydantic’s model_fields: an Estimate-typed field flattens into four columns (its name, plus lb/ub/open_side); a binomial_set field (see :class:~increment.estimation.results. BinomialConfidenceSet) flattens into set_lower/set_upper/ set_level and set_numerical_qualification — always the row’s confidence-set bounds/level and arithmetic scope; set-only rows may expose their binomial bounds in lb/ub despite having no point estimate. These are also recorded in the set_* columns; every other field passes through as a scalar column in declaration order. Most callers should use results.to_frame() on a pipeline’s own result rather than calling this function directly.

estimates : Sequence[M] Any sequence of one supported result model. May be empty. model : type[M] | None Which model estimates holds. Required when estimates is empty, since an empty sequence carries no runtime type trace. backend : Backend | None Native dataframe backend to build. When omitted, pandas is preferred, then polars, then pyarrow. Collections created from dataframe input default to that input’s backend.

columns : Sequence[str] | None Select known projection columns in canonical order. None keeps every projection column.

IntoDataFrame One row per estimate, columns in the model’s field order, with the Estimate-typed field expanded to <field name>/lb/ub/open_side and a binomial_set field expanded to set_lower/set_upper/ set_level/set_numerical_qualification. open_side is "lower"/"upper" only for a point-backed genuinely unbounded endpoint; None for a closed interval and whenever there is no point estimate, including set-only rows (whose bounds are in lb/ub).

impute

Explicit missing-value repairs for dataframe entry paths.

from_unit_summary/from_unit_panel refuse null or NaN metric values by default, since either can silently produce a wrong number (zero-averaged or backend-inconsistent sums) with no warning. This module is the helper tier of the named fixes for callers holding the dataframe; warehouse users instead declare MetricSpec(missing=...), which needs no source mutation.

Helpers are narwhals-based and backend-agnostic, returning the same native frame type that came in, and treat null/NaN identically as “missing” since NaN is a real value (not skipped by sums) on polars/pyarrow but not pandas. Each helper returns (frame, affected_count), so a repair is always visible and loggable.