First, create a measurement with the Polars API:
>>> import opendp.prelude as dp
>>> import polars as pl
>>> dp.enable_features("contrib")
>>> lf = pl.LazyFrame(schema={"A": pl.Int32, "B": pl.String})
>>> lf_domain = dp.lazyframe_domain([
>>> lf_domain = dp.with_margin(lf_domain, dp.polars.Margin(by=[], max_length=1000))
>>> meas = dp.m.make_private_lazyframe(
This function extracts utility information about each aggregate in the resulting data frame:
>>> dp.summarize_polars_measurement(meas)
shape: (2, 4)
┌────────┬──────────────┬─────────────────┬───────┐
│ column ┆ aggregate ┆ distribution ┆ scale │
│ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ str ┆ str ┆ f64 │
╞════════╪══════════════╪═════════════════╪═══════╡
│ len ┆ Frame Length ┆ Integer Laplace ┆ 1.0 │
│ A ┆ Sum ┆ Integer Laplace ┆ 1.0 │
└────────┴──────────────┴─────────────────┴───────┘
If you pass an alpha argument, then you also get accuracy estimates:
>>> dp.summarize_polars_measurement(meas, alpha=.05)
shape: (2, 5)
┌────────┬──────────────┬─────────────────┬───────┬──────────┐
│ column ┆ aggregate ┆ distribution ┆ scale ┆ accuracy │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ str ┆ str ┆ f64 ┆ f64 │
╞════════╪══════════════╪═════════════════╪═══════╪══════════╡
│ len ┆ Frame Length ┆ Integer Laplace ┆ 1.0 ┆ 3.375618 │
│ A ┆ Sum ┆ Integer Laplace ┆ 1.0 ┆ 3.375618 │
└────────┴──────────────┴─────────────────┴───────┴──────────┘