Skip to content

Commit 840659c

Browse files
deploy: 71b7005
1 parent b0768a9 commit 840659c

66 files changed

Lines changed: 1399 additions & 1241 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

404.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313

1414

1515
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css" integrity="sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM" crossorigin="anonymous"><link rel="stylesheet" href="/assets/css/styles.66a6f7b1.css">
16-
<link rel="preload" href="/assets/js/runtime~main.ab1d9599.js" as="script">
17-
<link rel="preload" href="/assets/js/main.08f331b9.js" as="script">
16+
<link rel="preload" href="/assets/js/runtime~main.db2451a7.js" as="script">
17+
<link rel="preload" href="/assets/js/main.14546265.js" as="script">
1818
</head>
1919
<body class="navigation-with-keyboard">
2020
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script>
2121
<div style="display: none; text-align: center; background-color: white; color: black;" id="internaldocs-banner"></div><div id="__docusaurus">
2222
<div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/balance_logo/icon.svg" alt="balance Logo" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/balance_logo/icon.svg" alt="balance Logo" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">balance</b></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/blog/">Blog</a><a class="navbar__item navbar__link" href="/docs/docs/overview/">Docs</a><a class="navbar__item navbar__link" href="/docs/tutorials/">Tutorials</a><a class="navbar__item navbar__link" href="/docs/api_reference/">API Reference</a><a class="navbar__item navbar__link" href="/docs/docs/changelog/">Changelog</a><a href="https://github.com/facebookresearch/balance" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><div class="searchBox_ZlJk"><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input id="search_input_react" type="search" placeholder="Loading..." aria-label="Search" class="navbar__search-input search-bar" disabled=""></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0"><main class="container margin-vert--xl"><div class="row"><div class="col col--6 col--offset-3"><h1 class="hero__title">Page Not Found</h1><p>We could not find what you were looking for.</p><p>Please contact the owner of the site that linked you to the original URL and let them know their link is broken.</p></div></div></main></div><footer class="footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Legal</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://opensource.fb.com/legal/privacy/" target="_blank" rel="noopener noreferrer" class="footer__link-item">Privacy<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://opensource.fb.com/legal/terms/" target="_blank" rel="noopener noreferrer" class="footer__link-item">Terms<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://opensource.fb.com/legal/data-policy/" target="_blank" rel="noopener noreferrer" class="footer__link-item">Data Policy<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://opensource.fb.com/legal/cookie-policy/" target="_blank" rel="noopener noreferrer" class="footer__link-item">Cookie Policy<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div></div><div class="footer__bottom text--center"><div class="margin-bottom--sm"><a href="https://opensource.fb.com" rel="noopener noreferrer" class="footerLogoLink_BH7S"><img src="/img/meta_opensource_logo_negative.svg" alt="Meta Open Source Logo" class="themedImage_ToTc themedImage--light_HNdA footer__logo"><img src="/img/meta_opensource_logo_negative.svg" alt="Meta Open Source Logo" class="themedImage_ToTc themedImage--dark_i4oU footer__logo"></a></div><div class="footer__copyright">
2323
Copyright © 2026 Meta Platforms, Inc. Built with Docusaurus.<br>
2424
Documentation Content Licensed Under <a href="https://creativecommons.org/licenses/by/4.0/">CC-BY-4.0</a>.<br></div></div></div></footer></div>
25-
<script src="/assets/js/runtime~main.ab1d9599.js"></script>
26-
<script src="/assets/js/main.08f331b9.js"></script>
25+
<script src="/assets/js/runtime~main.db2451a7.js"></script>
26+
<script src="/assets/js/main.14546265.js"></script>
2727
</body>
2828
</html>

_src/docs/changelog.md

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ hide_title: true
115115

116116
# 0.22.0 (2026-07-15)
117117

118+
## Breaking Changes
119+
120+
- **IPW fit metadata renames its training-weight keys.** `ipw(...)["model"]` now
121+
stores training design weights under the canonical `training_sample_weights` /
122+
`training_target_weights` keys used by `predict_weights()`; the old
123+
`fit_sample_weights` / `fit_target_weights` keys are no longer emitted.
124+
**Migration:** downstream code that reads the model dict directly should switch
125+
to the `training_*` names.
126+
- **Rake model metadata no longer emits the IPW-style `perf` placeholder** with a
127+
synthetic NaN deviance-explained value.
128+
**Migration:** use rake-specific metadata such as `iterations` and `converged`.
129+
118130
## New Features
119131

120132
- `BalanceDFOutcomes.relative_response_rates()` now accepts an explicit `relative_to={"self", "target"}` denominator selector while preserving the existing `target=` API.
@@ -124,13 +136,9 @@ hide_title: true
124136

125137
## Code Quality & Refactoring
126138

127-
- **Breaking:** IPW fit metadata now stores training design weights under the
128-
canonical `training_sample_weights` / `training_target_weights` keys used by
129-
`predict_weights()`. The old `fit_sample_weights` / `fit_target_weights`
130-
model-dict keys are no longer emitted; downstream code that reads
131-
`ipw(...)["model"]` directly should switch to the `training_*` names. Stored
132-
fit matrices are copied before being persisted so sample and target caches
133-
cannot share slice views with the fit-time design matrix.
139+
- IPW stored fit matrices are copied before being persisted so sample and target
140+
caches cannot share slice views with the fit-time design matrix. (The
141+
accompanying `training_*` metadata key rename is listed under Breaking Changes.)
134142
- ASMD input validation now rejects duplicate DataFrame column labels before
135143
computing statistics, making direct `asmd(...)` calls match the unique-column
136144
invariant enforced by SampleFrame construction.
@@ -141,9 +149,6 @@ hide_title: true
141149
- Rake now uses the shared weighting-method input validator already used by
142150
IPW and poststratify, so DataFrame/weight type, length, and index checks are
143151
reported consistently across all three methods.
144-
- **Breaking:** Rake model metadata no longer emits the IPW-style `perf` placeholder with a
145-
synthetic NaN deviance-explained value; consumers should use rake-specific
146-
metadata such as `iterations` and `converged`.
147152
- Transfer-scoring guards for rake and poststratify now reject `functools.partial(...)` wrappers around known data-dependent transformation helpers (`quantize` / `fct_lump`), closing a replay-safety gap where partial-wrapped helpers could bypass direct callable checks.
148153
- Rake now uses the shared adjustment warning helper when fit metadata is stored with `transformations="default"`, keeping transfer-scoring guidance centralized with the corresponding replay-safety guard.
149154

@@ -166,6 +171,15 @@ hide_title: true
166171

167172
# 0.21.0 (2026-06-02)
168173

174+
## Breaking Changes
175+
176+
- **Poststratify models pickled before 0.21.0 cannot be used for transfer
177+
scoring.** They lack the `transformations_origin` metadata that
178+
`predict_weights(data=...)` needs to replay cell ratios safely. In-place
179+
`predict_weights()` continues to work.
180+
**Migration:** re-fit the model on the current version before transfer scoring.
181+
See the poststratify entry under New Features for details.
182+
169183
## New Features
170184

171185
- **`balance.stats_and_plots.love_plot.love_plot`, `BalanceDFCovars.love_plot()`,
@@ -242,8 +256,8 @@ hide_title: true
242256

243257
## Bug Fixes
244258

245-
- **`rake()` now correctly incorporates per-row design weights in final
246-
weights.** Previously, every unit in the same raking cell received the same
259+
- **Numerical change: `rake()` now correctly incorporates per-row design weights
260+
in final weights.** Previously, every unit in the same raking cell received the same
247261
weight `m_fit[c] / m_sample[c]`, ignoring its own design weight. The correct
248262
formula `w_final_i = w_design_i × m_fit[c] / m_sample[c]` is now applied,
249263
matching `poststratify` semantics and ensuring weighted marginals recover
@@ -745,6 +759,16 @@ expansion, data flow, and the `Sample.__new__` guard — see
745759

746760
# 0.16.0 (2026-02-09)
747761

762+
## Breaking Changes
763+
764+
- **Require positive weights for weight diagnostics that normalize or aggregate**
765+
- `design_effect`, `nonparametric_skew`, `prop_above_and_below`, and
766+
`weighted_median_breakdown_point` now raise a `ValueError` when all weights
767+
are zero.
768+
- **Migration:** ensure your weights include at least one positive value
769+
before calling these diagnostics, or catch the `ValueError` if all-zero
770+
weights are possible in your workflow.
771+
748772
## New Features
749773

750774
- **Outcome weight impact diagnostics**
@@ -790,17 +814,20 @@ expansion, data flow, and the `Sample.__new__` guard — see
790814
- **Direct util imports in tests**
791815
- Refactored util test modules to import helpers directly from their modules instead of via `balance_util`.
792816

793-
## Breaking Changes
817+
# 0.15.0 (2026-01-20)
794818

795-
- **Require positive weights for weight diagnostics that normalize or aggregate**
796-
- `design_effect`, `nonparametric_skew`, `prop_above_and_below`, and
797-
`weighted_median_breakdown_point` now raise a `ValueError` when all weights
798-
are zero.
799-
- **Migration:** ensure your weights include at least one positive value
800-
before calling these diagnostics, or catch the `ValueError` if all-zero
801-
weights are possible in your workflow.
819+
## Breaking Changes
802820

803-
# 0.15.0 (2026-01-20)
821+
- **Numerical change: `poststratify()` now treats missing values as their own
822+
category by default**, filling poststratification variables with `"__NaN__"`.
823+
Previously their treatment depended on pandas `groupby` / `merge` defaults.
824+
**Migration:** pass `na_action="drop"` to approximate the legacy behaviour. See
825+
the poststratify entry under New Features.
826+
- **Numerical change: `model_matrix(add_na=False)` now actually drops rows
827+
containing NA**, where it previously only logged a warning. Code relying on the
828+
old behaviour may see fewer rows.
829+
**Migration:** handle missingness explicitly or pass `add_na=True`. See the
830+
entry under Bug Fixes.
804831

805832
## New Features
806833

@@ -813,7 +840,8 @@ expansion, data flow, and the `Sample.__new__` guard — see
813840
- **Improved missing data handling in `poststratify()`**
814841
- `poststratify()` now accepts `na_action` to either drop rows with missing
815842
values or treat missing values as their own category during weighting.
816-
- **Breaking change:** the default behavior now fills missing values in
843+
- **Default change** (listed under Breaking Changes): the default behavior now
844+
fills missing values in
817845
poststratification variables with `"__NaN__"` and treats this as a distinct
818846
category during weighting. Previously, missing values were not handled
819847
explicitly, and their treatment depended on pandas `groupby` and `merge`
@@ -896,6 +924,18 @@ expansion, data flow, and the `Sample.__new__` guard — see
896924

897925
# 0.14.0 (2025-12-14)
898926

927+
## Breaking Changes
928+
929+
- **`Sample.diagnostics()` for IPW now always emits iteration/intercept summaries
930+
plus hyperparameter settings.**
931+
**Migration:** code that indexes diagnostics rows positionally, or asserts on an
932+
exact row count, needs updating. See the entry under Code Quality & Refactoring.
933+
- **Numerical change: percentile-based weight clipping may shift by roughly one
934+
observation at typical limits**, after `trim_weights()` moved to percentile
935+
quantiles with explicit clipping bounds for cross-platform consistency.
936+
**Migration:** none required, but re-check any hard-coded expected weights. See
937+
the entry under Bug Fixes.
938+
899939
## New Features
900940

901941
- **Enhanced adjusted sample summary output**
@@ -923,7 +963,8 @@ expansion, data flow, and the `Sample.__new__` guard — see
923963
- **Consolidated diagnostics helpers**
924964
- Added `_concat_metric_val_var()` helper and `balance.util._coerce_scalar`
925965
for robust diagnostics row construction and scalar-to-float conversion.
926-
- **Breaking change:** `Sample.diagnostics()` for IPW now always emits
966+
- **Behaviour change** (listed under Breaking Changes): `Sample.diagnostics()`
967+
for IPW now always emits
927968
iteration/intercept summaries plus hyperparameter settings.
928969

929970
## Bug Fixes
@@ -935,7 +976,8 @@ expansion, data flow, and the `Sample.__new__` guard — see
935976
- `trim_weights()` now computes thresholds via percentile quantiles with
936977
explicit clipping bounds for consistent behavior across Python/NumPy
937978
versions.
938-
- **Breaking change:** percentile-based clipping may shift by roughly one
979+
- **Numerical change** (listed under Breaking Changes): percentile-based
980+
clipping may shift by roughly one
939981
observation at typical limits.
940982
- **IPW diagnostics improvements**
941983
- Fixed `multi_class` reporting, normalized scalar hyperparameters to floats,
@@ -1105,11 +1147,12 @@ expansion, data flow, and the `Sample.__new__` guard — see
11051147
`value_counts(dropna=False)` with `groupby().size()` in frequency table
11061148
creation to avoid FutureWarning
11071149
- Fixed various pandas deprecation warnings and improved DataFrame handling
1108-
- **Improved raking algorithm** - Completely refactored rake weighting from
1109-
DataFrame-based to array-based ipfn algorithm using multi-dimensional arrays
1110-
and itertools for better performance and compatibility with latest Python
1111-
versions. **Variables are now automatically alphabetized** to ensure
1112-
consistent results regardless of input order.
1150+
- **Numerical change: improved raking algorithm** - Completely refactored rake
1151+
weighting from DataFrame-based to array-based ipfn algorithm using
1152+
multi-dimensional arrays and itertools for better performance and compatibility
1153+
with latest Python versions. **Variables are now automatically alphabetized** to
1154+
ensure consistent results regardless of input order, so raking a given input can
1155+
produce different weights than in 0.10.0.
11131156
- **poststratify method enhancement** - New `strict_matching` parameter (default
11141157
True) handles cases where sample cells are not present in target data. When
11151158
False, issues warning and assigns weight 0 to uncovered samples
@@ -1156,10 +1199,10 @@ expansion, data flow, and the `Sample.__new__` guard — see
11561199
- Dependency on glmnet has been removed, and the `ipw` method now uses sklearn.
11571200
- The transition to sklearn should enable support for newer python versions
11581201
(3.11) as well as the Windows OS!
1159-
- `ipw` method uses logistic regression with L2-penalties instead of
1160-
L1-penalties for computational reasons. The transition from glmnet to sklearn
1161-
and use of L2-penalties will lead to slightly different generated weights
1162-
compared to previous versions of Balance.
1202+
- **Numerical change:** the `ipw` method uses logistic regression with
1203+
L2-penalties instead of L1-penalties for computational reasons. The transition
1204+
from glmnet to sklearn and use of L2-penalties will lead to slightly different
1205+
generated weights compared to previous versions of Balance.
11631206
- Unfortunately, the sklearn-based `ipw` method is generally slower than the
11641207
previous version by 2-5x. Consider using the new arguments `lambda_min`,
11651208
`lambda_max`, and `num_lambdas` for a more efficient search over the `ipw`
@@ -1191,7 +1234,7 @@ expansion, data flow, and the `Sample.__new__` guard — see
11911234
- Added links to presentation given at ISA 2023.
11921235
- Fixed misc typos.
11931236

1194-
# 0.9.0 (2023-05-22)
1237+
# 0.9.0 (2023-05-22)
11951238

11961239
## News
11971240

0 commit comments

Comments
 (0)