OI Workforce DML
Changes in 0.5.0
Prediction frames now use outcome and treatment throughout calculation,
saving, and plotting. Saved predictions no longer duplicate the outcome under
its original source name; the summary and model metadata retain that name.
Update scripts that read the original outcome column from prediction files.
The estimation workflow separates fitting/calculation from saving/plotting.
Internal RCT naming is now program_is_rct, matching the program registry;
YAML settings and existing summary column names are unchanged. RCT calculation
errors still preserve the main estimates; file-writing errors use the normal
per-run output-failure handling.
Calibration plots share preparation and binning, including the adaptive
low-propensity view. Multiple-run calibration now excludes nonfinite values
consistently with single-run calibration. Run durations stop after calculation,
before saving and plotting. Legacy combined prediction files, common-fold
files, and the old log_results wrapper are no longer supported.
The manual plot_rct_match_validation scatterplot has been removed from this
package; its replacement is being developed separately in dml-plotting.
Automatic estimation diagnostics are unchanged. Estimator formulas and model
fitting are unchanged from 0.4.0.
Changes in 0.4.0
Outcome models are fitted once per configuration and reused across sites. Outcome cross-fitting now uses two folds; propensity cross-fitting uses five, with separate assignments. These changes can change estimates relative to 0.3.0. The YAML format remains unchanged.
This release also preserves all-null categorical columns for LightGBM/SHAP,
exposes rebuild_master_summary from the package root, and simplifies the
estimation workflow. Use a new output directory or experiment name when comparing
against an earlier release.
Cross-fitted outcome, IPW, and AIPW estimation with saved models and diagnostics. Supply prebuilt data using the input contract below.
Version 0.3 migration
The Python package has been renamed from dml_code to oi_workforce_dml.
Update imports in your scripts and registries; dml-estimate and YAML settings
are unchanged. Previously saved joblib/pickle models may reference dml_code;
load those with version 0.2.0 in a separate environment, or refit them with 0.3.0.
Version 0.2 migration
Version 0.2 runs estimation on prebuilt inputs. It no longer includes the old
build command or bundled project configuration. Copy example_set_up/ from the
source distribution or repository, fill in the registries, and pass the YAML
experiment path to dml-estimate.
Replace tune_nuisance_models / n_tuning_trials with independent
outcomes_tune / outcomes_tuning_trials and
propensity_tune / propensity_tuning_trials. Remove drop_nulls and
calculate_on_control_placebo; covariate missingness is handled by the models,
and RCT-control evaluation follows the program registry. Unknown settings are
rejected. The examples below use the current format.
Install and run
The PyPI distribution is oi-workforce-dml; the Python import is
oi_workforce_dml, and the command remains dml-estimate. The GitHub repository is
oi-workforce-dml. If the old dml-dev distribution is installed in this environment,
uninstall it first (python -m pip uninstall dml-dev): both distributions
provide the same dml-estimate command.
# Install the published package:
python -m pip install oi-workforce-dml==0.5.0
# Or install a local checkout:
python -m pip install /path/to/oi-workforce-dml
# Or for development: python -m pip install -e /path/to/oi-workforce-dml
dml-estimate /path/to/my_analysis/experiment.yaml
# Equivalent:
python -m oi_workforce_dml.cli /path/to/my_analysis/experiment.yaml
from oi_workforce_dml import estimate
estimate("/path/to/my_analysis/experiment.yaml")
To rebuild master_summary.xlsx from the saved experiment summaries without
rerunning estimation, use the same output directory configured in your YAML:
from pathlib import Path
from oi_workforce_dml import rebuild_master_summary
rebuild_master_summary(output_dir=Path("/path/to/my_analysis/results"))
The experiment name comes from the YAML filename (experiment above).
The command can run from any working directory. YAML is parsed safely; Python
experiment configurations are no longer accepted. example_set_up/ is a
copyable checkout example, outside the installed package. It contains sibling
experiments/ and registries/ directories; supply your own processed inputs.
YAML experiment configuration
registry_dir: ../registries
output_dir: ../results
experiments:
- program_name: [my_program]
outcomes: [wages_2]
covariate_set_name: [baseline]
filter_set_name: [eligible]
outcomes_model_name: [lightgbm]
outcomes_tune: [false]
propensity_model_name: [lightgbm]
propensity_tune: [false]
group_col: [site]
delete_raw_predictions: [false]
registry_dir and output_dir resolve relative to the YAML file, or can be
absolute. The registry directory contains these fixed Python files:
| File | Dictionary |
|---|---|
programs.py |
PROGRAM_REGISTRY |
covariate_sets.py |
COVARIATE_SET_REGISTRY |
filter_sets.py |
FILTER_SET_REGISTRY |
models.py |
OUTCOMES_MODEL_REGISTRY, PROPENSITY_MODEL_REGISTRY |
Registry dictionaries map names to program definitions, covariate lists,
lists of Polars filter functions, and supported sklearn/LightGBM model instances. They remain
executable Python; load registry files you trust. Bare sibling imports,
package imports such as from registries.models import ..., and relative
imports such as from .models import ... are supported. Sibling modules are
isolated between configs loaded sequentially in one Python process.
Experiment fields remain lists and expand into combinations. Multiple blocks
are allowed. Model templates are cloned for each run/fold. dml_type is not
accepted. Unknown top-level and experiment settings are rejected. Optional defaults:
no tuning, no grouping ([] or [null]), and retain predictions.
Missing covariates are retained; rows missing identity, treatment, or outcome are dropped.
Set outcomes_tune: [true] with outcomes_tuning_trials: [15] to tune outcomes;
use propensity_tune and propensity_tuning_trials independently for propensity.
False uses the registry preset. True uses the built-in tuning recipe before
cross-fitting. Omit a learner's trial budget when it is not tuned. For a mixed
[false, true] grid, budgets expand tuned runs only; the preset runs once.
Grouping generates a pooled run plus each non-null group with at least
30 treated rows in the input. Each group uses its treated rows and all controls.
For each configuration combination, data and filters are loaded once. The pooled
outcome fit adds predictions and outcome folds to that dataframe, then the site
loop selects each site's treated rows plus all controls. Propensity tuning,
fold assignment, and fitting remain site-specific. Outcomes use two folds and
propensity uses five, set by OUTCOMES_N_FOLDS and PROPENSITY_N_FOLDS in
nuisance.py. Each learner excludes its own held-out fold during fitting; these
are separate partitions rather than the original common-partition DML scheme.
The summary records outcomes_source_run_number and outcomes_reused. Shared
preparation/outcome failure skips that configuration's pooled and site runs;
a later propensity or output failure affects only its own run. Outcome fitting
is repeated for the next configuration combination, not reused across programs
or restarts. Site estimates can differ from independent fits because outcome
tuning and outcome fold assignments come from the pooled run.
Filters select rows only: do not transform covariates, because plotting later
reloads their values from the source file.
Model presets and tuning
The model registries contain ordinary model instances. Supported families are LightGBM, Lasso (outcomes) / LogisticRegression (propensity), random forests, MLP neural networks, and VotingRegressor / soft VotingClassifier ensembles. The example model registry contains a preset for each. Ensemble members use fixed presets and weights; requesting ensemble tuning is an error.
Each learner has its own *_tune switch and *_tuning_trials budget. False
uses the registry preset. True clones that preset and overrides the parameters
in the built-in tuning recipe, retaining parameters outside that recipe. Tuning
happens once before cross-fitting, using the existing 80/20 split, outcome MSE
on controls, and binary log loss for propensity. The best LightGBM iteration
count is retained after early stopping. Search spaces live in nuisance.py:
| Family | Outcomes | Propensity |
|---|---|---|
| LightGBM | Existing outcome tree search | Existing constrained propensity tree search |
| Linear | Lasso regularization | L1 logistic regularization, favoring stronger penalties |
| Forest | Deeper trees, smaller leaves | Shallower trees, larger leaves |
| Neural net | Larger hidden layers, lighter regularization | Smaller layers, stronger regularization |
These are starting ranges, not guarantees of calibration or adequate overlap. A small trial budget explores only a few parameters. Manual presets remain the way to choose other settings. Existing seeds and CPU detection are unchanged.
preprocessing.py attaches training-only pipelines automatically. Non-LightGBM
models impute numeric missing values and encode categories with sparse indicator
columns (unseen categories are ignored). Linear models and neural nets also
scale numeric features. Lasso and neural-net outcomes additionally standardize
the training target; their regularization is in standardized-outcome units and
predictions are transformed back to the original units. Saved fold models include
all these fitted transformations. Each ensemble member owns its preprocessing.
LightGBM keeps its native categorical and missing-value handling.
SHAP diagnostics currently support LightGBM only. Other families still get the standard calibration, propensity, and balance plots; SHAP is explicitly skipped.
Processed input contract
Use a plain program dictionary with exactly the output path and RCT flag:
from pathlib import Path
HERE = Path(__file__).resolve().parent
PROGRAM_REGISTRY = {
"my_program": {
"program_output_path": HERE / "processed_inputs" / "my_program",
"program_is_rct": True,
},
}
Select programs through experiments[*].program_name. Multiple programs per
experiment work. Use absolute program output paths; anchoring them to
__file__ avoids dependence on where the command is run. For a non-RCT
program set program_is_rct=False.
The program output folder contains:
processed_data.parquet: treated people and the comparison pool.rct_control_set_aside.parquet: separate held-out RCT controls, when applicable.
RCT-control placebo evaluation runs automatically when program_is_rct=True.
A missing or invalid RCT file does not discard the main estimates: the summary
records rct_status (success, failed, or not_applicable) and rct_error.
Each rerun clears that run's previous RCT predictions and plots before attempting
the calculation, and replaces its summary values. The input must contain
pik, treatment, the selected outcome/covariates, and the configured group
column. RCT rows keep treatment=0. Processed inputs supply categorical types;
estimation preserves native categoricals for LightGBM and automatically prepares
other supported model families as described above.
observation_year is not required unless selected as a covariate/group/outcome.
Saved results and plotting
During estimation, diagnostics reuse the full prediction frames already in
memory, avoiding prediction-file reads and covariate joins. Saved predictions
remain slim. Standalone plots retain the file-loading behavior below.
generate_plots() and the standard single-run diagnostic helpers also accept
optional predictions (a Polars DataFrame or LazyFrame with this run's full
columns). For RCT overlap, pass its distinct control_placebo_predictions frame;
never substitute the main sample for the held-out RCT controls.
Under output_dir, the existing layout is retained:
raw/<experiment>/: parquet summaries, per-run predictions, and model files.plots/<experiment>/run_<number>/: diagnostic plots.tables/<experiment>/run_<number>/: diagnostic tables.master_summary.xlsx: summaries for experiments under this output root.
Reruns overwrite each run's prediction/model files and replace its summary row by run number. Nothing is cleared at startup; other summary rows remain, including runs not reached after an interruption. If you change the experiment combinations, use a new filename/output root to avoid retaining obsolete run numbers from the previous specification. Do not run the same experiment destination concurrently or write the shared master workbook concurrently.
Prediction files keep person ID, treatment, observed outcome (outcome), model predictions, run number, configured group column,
and learner-specific main-sample fold assignments
(outcomes_held_out_fold_rep_1 and propensity_held_out_fold_rep_1). Other covariates are omitted. The parquet
summary already records covariate_set; it now also records data_path and
control_placebo_path as absolute paths. Existing model names and parameter
strings remain. Fold models and their feature order remain in .joblib files.
Saved-output readers require the current per-run prediction files and separate outcome/propensity fold columns; legacy combined files and common-fold files are no longer supported. Reported run durations stop after calculations, before saving and plotting. The pooled run includes shared outcome fitting; subsequent site runs report only their own work.
Balance plots and model/SHAP loading recover requested covariates from the
saved source paths, joining by unique pik. Duplicate source IDs, unmatched
prediction IDs, and ambiguous summary rows are rejected. Keep source files
available and unchanged for later diagnostics. Filters are not reapplied.
from pathlib import Path
import polars as pl
from oi_workforce_dml.src.plotting import generate_plots
output_dir = Path("/secure/results")
summary = pl.read_parquet(output_dir / "raw/experiment/log_summary.parquet")
row = summary.filter(pl.col("run_number") == 1).row(0, named=True)
generate_plots("experiment", 1, row["covariate_set"], output_dir=output_dir)
The balance plot keeps its existing preferred list, skips covariates absent
from the run, and skips entirely when none remain. Categorical covariates use
category indicators. Calibration includes full-range and adaptive low-propensity
views (90th percentile cutoff, 20 bins); outcome axes adapt to the bin means and
confidence intervals without selecting on realized outcomes. Only small bin
summaries are converted to pandas. Diagnostics fail independently and return a
failure dictionary. Set include_control_placebo=True only when its saved
outputs are available.
Propensity SHAP uses each person's held-out model in repetition 1. Its overall
sample is capped at 50,000 across all folds; treated summaries include everyone.
Outcome SHAP uses repetition 1's fold 1 model, all treated people for the treated
summary, and held-out fold 1 rows for its overall plots. Magnitude tables are
written before plot rendering. Setting
delete_raw_predictions=[True] deletes prediction logs after current plots;
later model/SHAP plotting requires those logs and will not reconstruct them.
Package layout and checks
oi_workforce_dml/cli.py: terminal argument parsing.oi_workforce_dml/estimation.py: run orchestration, exposed asestimate().oi_workforce_dml/src/config.py: YAML, registries, Experiment/Run definitions, expansion and validation.oi_workforce_dml/src/nuisance.py: tuning, folds, fitting and nuisance predictions.oi_workforce_dml/src/preprocessing.py: model validation and training-only transformations.oi_workforce_dml/src/estimate_helpers.py: preparation, ATT/variance and RCT-control evaluation.oi_workforce_dml/src/results.py: summaries, saved predictions/models and upserts.oi_workforce_dml/src/plotting.py:generate_plots()and individual diagnostics.oi_workforce_dml/src/paths.py,utils.py: paths and shared utilities.
From a checkout, after installing the package:
python -m unittest discover -s tests/integration -v
Tests generate their own synthetic processed inputs and exercise real LightGBM fits, estimator formulas, summary upserts, registry isolation and diagnostics.
Metadata
Release files for oi-workforce-dml 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oi_workforce_dml-0.5.0.tar.gz | 39.2 kB | With provenance | Details for oi_workforce_dml-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oi_workforce_dml-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for oi_workforce_dml-0.5.0-py3-none-any.whl |
Total release size: 81.4 kB
Release files / oi_workforce_dml-0.5.0.tar.gz
| Download URL | oi_workforce_dml-0.5.0.tar.gz |
|---|---|
| Size | 39.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3dc5bec60858da1324d3dfa1345620ea20035e7b5396c1331a21cb6a64e28648
|
|
BLAKE2b-256 checksum How to use checksums |
7399a1609a3914233ec8755649b334c990059cb38559e3fdf4ac3dfcb19357af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logRelease files / oi_workforce_dml-0.5.0-py3-none-any.whl
| Download URL | oi_workforce_dml-0.5.0-py3-none-any.whl |
|---|---|
| Size | 42.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2efb553d8618485b1f36bb709cce221571d8149ecb5775c42c81062e2fa4aa06
|
|
BLAKE2b-256 checksum How to use checksums |
335db4aa11729ebfd5cd8c17c25a967f817558a04f0af2b12371f29a642d5a51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logSecurity for oi-workforce-dml 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for oi_workforce_dml-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.