Complete a specific task with the public panel APIs
These recipes assume familiarity with the estimate panel. The executable examples use the same fixtures as the tutorials. In application code, replace those fixtures with the caller’s estimate panel.
Publish an anchored feed
Inputs: Supply a long panel, an exclusive UTC reading moment, the forecast source name and externally fitted parameters.
Parameter dates: The training window must end before the publication date.
Output selection: Request expected_surprise for a fraction relative to consensus. Request anchored_level separately when a level is needed.
import pandas as pdimport pf as examplesimport postforecast as pfcestimates = examples.example_panel()parameters = pfc.AnchoringParameters.model_validate( pfc.STUDY_2025_01.model_dump(mode="json"))feed = pfc.publish_anchored( estimates, pd.Timestamp("2026-01-20", tz="UTC"), forecast_source="model", parameters=parameters, fields=("expected_surprise",),)feed[["entity", "period", "expected_surprise", "eligible", "eligibility_reason"]]
entity
period
expected_surprise
eligible
eligibility_reason
0
ZS
2026Q1
0.032968
True
publishable
Real parameters: Replace the tutorial’s shipped parameter payload with the approved artifact for the consuming application. File loading stays with the caller.
Explicit universe: Pass subjects= to retain requested subjects even when they have no known observations. Refused subjects keep a row and a reason.
Units: A surprise of 0.03 means 3%. Raw source levels are excluded from this publication API.
Reading policy: Publication uses the reference 30-day revision with a 60-day maximum age at each revision read. Use prepare_anchored_subjects and AnchoredEstimate when a different preparation policy is required.
Configure Bayesian predictions
Use bayesian_kpi_predictions for the complete reference workflow. The panel needs reported actuals and historical estimates as well as live predictions.
Historical output: Set series="backtests" for historical estimates fitted on strictly earlier observations. Set series="combined" for the stitched series.
Separate model histories: Pass backtest_source= when historical model estimates have a different source identifier from live predictions.
Training start: Set start_date in the settings to restrict the training sample. Filter display dates after calculation to retain the intended history.
Dispersion weighting: Set stdev_weighted_consensus=True and supply consensus dispersion. Count weighting additionally uses estimate_count and consensus_count_exponent. See the precision rules.
Publication horizons: For the independent method, set relative_to="publish" and a nonpositive relative_days, or "latest". Pass a publications frame with subject keys and UTC publication_date. See the publication-relative contract.
To use correlation adjustment, construct compatible settings:
Malformed panel:PanelError reports a contract violation; correct the input before calling again.
Anchored refusal: Requested numeric outputs are missing and the subject remains in the result.
Bayesian refusal: Diagnostics can remain populated even when the prediction is unavailable. A finite diagnostic alone does not make a row publishable.
Missing interval: The independent reference can produce a prediction without an interval when model precision is unavailable. See the independent reference.
Retain an audit record
Store the complete parameter or settings payload alongside the output. A version identifier alone cannot reconstruct the calculation.
Inputs: Retain the input snapshot or its reproducible identifier, the reading moment and the source identifiers in the consuming application.
Parameters: Keep the full payload, its version and fitted-through date when applicable. Settings chosen rather than fitted have no fitted-through date.
Software: Record the installed package revision alongside the run.
Outputs: Preserve subject keys, method, version and refusal status when combining results across sources or parameter sets.
Persistence: The caller writes the record; the library performs no file or network I/O.