Skip to content
This repository was archived by the owner on Nov 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/CONTRIBUTING.md

This file was deleted.

12 changes: 0 additions & 12 deletions .github/has-functional-changes.sh

This file was deleted.

33 changes: 0 additions & 33 deletions .github/is-version-number-acceptable.sh

This file was deleted.

6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Microimpute

> PolicyEngine has archived microimpute. [Microcosm](https://github.com/PolicyEngine/microcosm) builds PolicyEngine's microdata and fits its imputation models with the `microcosm-fit` package. [PyPI](https://pypi.org/project/microimpute/) keeps the package's releases, so `pip install microimpute` still works. The [open issues](https://github.com/PolicyEngine/microimpute/issues) include correctness bugs that no release fixes, such as [the default QRF's miscalibrated quantiles](https://github.com/PolicyEngine/microimpute/issues/205).

Microimpute is a Python package for imputing variables from one survey dataset onto another. It wraps five imputation methods behind a common interface so you can benchmark them on your data and pick the one that works best, rather than defaulting to a single approach.

## Methods
Expand Down Expand Up @@ -39,10 +41,6 @@ For image export (PNG/JPG):
pip install microimpute[images]
```

## Contributing

Pull requests are welcome. If you find a bug or have a feature idea, open an issue or submit a PR.

## License

PolicyEngine releases the code in this repository under the [MIT License](https://github.com/PolicyEngine/microimpute/blob/main/LICENSE), and its original text and figures under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) with attribution to PolicyEngine. Third-party data and materials keep their own terms. The optional `matching` extra installs rpy2, which its authors license under GPL-2.0-or-later. The paper notebook `paper/imputing-from-scf-to-cps.ipynb` imports policyengine-us and policyengine-core, which carry AGPL-3.0.
1 change: 1 addition & 0 deletions changelog.d/retire-microimpute.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Point readers to Microcosm, which builds PolicyEngine's microdata, and mark the package inactive.
1 change: 1 addition & 0 deletions changelog.d/version-from-metadata.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Read `microimpute.__version__` from the installed package's metadata, so it matches the installed release instead of always reporting 1.1.2.
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Microimpute

> PolicyEngine has archived microimpute. [Microcosm](https://github.com/PolicyEngine/microcosm) builds PolicyEngine's microdata and fits its imputation models with the `microcosm-fit` package. [PyPI](https://pypi.org/project/microimpute/) keeps the package's releases, so `pip install microimpute` still works. The [open issues](https://github.com/PolicyEngine/microimpute/issues) include correctness bugs that no release fixes, such as [the default QRF's miscalibrated quantiles](https://github.com/PolicyEngine/microimpute/issues/205).

Microimpute is a Python package for imputing variables from one survey dataset onto another. It wraps five imputation methods behind a common interface so you can benchmark them on your data and pick the one that works best: impute one or multiple variables with any of the available methods, and compare their performance using quantile loss and log loss.

The package currently supports:
The package supports:
- Hot Deck Matching
- Ordinary Least Squares (OLS) Linear Regression
- Quantile Regression Forests (QRF)
- Quantile Regression
- Mixture Density Networks (MDN)

This is a work in progress and may evolve over time with new methods and features.

## Microimputation dashboard

To visualize imputation and benchmarking results, install Node.js, run `make dashboard` from the root of the [microimpute repository](https://github.com/PolicyEngine/microimpute), and open http://localhost:3000.
Expand Down
9 changes: 8 additions & 1 deletion microimpute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@
- Visualization: performance and comparison plots
"""

__version__ = "1.1.2"
from importlib.metadata import PackageNotFoundError, version as _version

try:
__version__ = _version("microimpute")
except PackageNotFoundError:
# Running from a source tree with no install. Keep it PEP 440 parseable so
# a consumer calling packaging.version.parse on it does not raise.
__version__ = "0.0.0+unknown"

# Import automated imputation
from microimpute.comparisons.autoimpute import AutoImputeResult, autoimpute
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ authors = [
{ name = "Nikhil Woodruff", email = "nikhil.woodruff@outlook.com" }
]
classifiers = [
"Development Status :: 7 - Inactive",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
Expand Down
63 changes: 63 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""The reported version must match the installed distribution.

`__init__.py` used to hard-code `__version__` as 1.1.2, which fell behind the
package's own version (3.1.1 by September 2026). These tests catch that drift.
"""

import subprocess
import sys
import textwrap
from importlib.metadata import version
from pathlib import Path

from packaging.version import Version

import microimpute

REPO_ROOT = Path(__file__).resolve().parents[1]


def test_version_matches_installed_distribution():
assert microimpute.__version__ == version("microimpute")


def test_version_is_pep440_parseable():
"""The fallback must parse too, or consumers comparing versions raise."""
Version(microimpute.__version__)
Version("0.0.0+unknown")


def test_fallback_used_when_distribution_is_absent():
"""Without a distribution to read, the package reports 0.0.0+unknown."""
# A fresh interpreter makes the metadata lookup for microimpute fail and
# then imports the package from this source tree, so the import runs the
# fallback branch in microimpute/__init__.py itself.
code = textwrap.dedent(
"""
import importlib.metadata as metadata
import sys

real_version = metadata.version


def missing(name):
if name == "microimpute":
raise metadata.PackageNotFoundError(name)
return real_version(name)


metadata.version = missing
sys.path.insert(0, sys.argv[1])
import microimpute

print(microimpute.__version__)
"""
)
result = subprocess.run(
[sys.executable, "-c", code, str(REPO_ROOT)],
capture_output=True,
text=True,
timeout=300,
)
assert result.returncode == 0, result.stderr
assert result.stdout.strip().splitlines()[-1] == "0.0.0+unknown"
Loading