PMAE
Official code for To Predict or Not to Predict? Proportionally Masked Autoencoders for Tabular Data Imputation (AAAI 2025). Jungkyu Kim, Kibok Lee, Taeyoung Park. [Paper] [arXiv] [PyPI]
💡 Why PMAE
Missingness differs from column to column, and the masking used to train an imputer should follow it. A masked autoencoder for imputation masks part of the observed entries during training and learns to predict them from the remaining ones.
- ReMasker (ICLR 2024) masks half of every row's tokens, choosing the missing entries first, so observed entries are masked only in rows that are more than half observed, whatever the column.
- PMAE masks the observed entries of column j with probability Mj = a · log((1 − pj) / pj) + b (a = 0.05, b = 0.5), where pj is the column's observed proportion in the batch; fully observed columns are never masked.
Idea. As in inverse probability weighting (Rosenbaum & Rubin, 1983; Seaman & White, 2013), what is observed less often should weigh more. In other words, the less a column is observed, the more of its entries become prediction targets.
🏗️ Architecture
row with masked entries
─► tokens numerical value → shared linear map, category → learned embedding; + position, [CLS]
─► encoder 6 blocks; masked and missing entries read as zero
─► decoder 4 blocks; a learned mask token at the masked and missing positions
─► heads a value per numerical column, a softmax over the categories per categorical column
─► loss per column, the mean error over its observed entries, masked or not (Eq. 4)
Both encoder and decoder stack pre-norm residual blocks of one of two types (Eqs. 12–13 of the paper):
| Mixing across columns | Mixing within a column token | |
|---|---|---|
| PMAE-trf | x ← x + SelfAttention(LN(x)), 4 heads | x ← x + MLP(LN(x)) |
| PMAE-mix | x ← x + MLPtokens(LN(x)), an MLP over the column axis | x ← x + MLP(LN(x)) |
Columns of tabular data often interact in groups rather than in pairs (T2G-Former, AAAI 2023). Self-attention combines columns through soft pairwise weights, whereas the non-linear token-mixing MLP of MLP-Mixer (NeurIPS 2021) can capture such group interactions more flexibly.
⚙️ Install
Python 3.10–3.12.
pip install pmae
To run the experiments, clone this repository and create the exact environment used for the results:
git clone https://github.com/normal-kim/PMAE.git && cd PMAE
conda env create -f environment.yml && conda activate pmae
🚀 Use PMAE on your own data
from pmae import PMAE
imputer = PMAE(blocks="mixer") # blocks="transformer" for PMAE-trf
X_filled = imputer.fit_transform(X, categorical=[3, 4])
X_new_filled = imputer.transform(X_new) # rows the imputer was not fit on
| Input | Shape | Type | Content |
|---|---|---|---|
X |
(n, d) |
float | numerical columns as values, categorical columns as integer codes 0 … K_j−1; NaN where missing |
categorical |
d_cat |
list of int | positions of the categorical columns |
It returns X with every missing entry filled: numerical values on the input scale, and a category code for every categorical entry.
Build your own imputer
Any object with fit(X, categorical) and transform(X) can be evaluated on the same scenarios. It receives the encoded splits (step 4 of the Pipeline below): quantile-normal numerical columns and integer category codes, with NaN where missing.
from pmae.run import run
class MyImputer:
def fit(self, X, categorical):
...
return self
def transform(self, X):
... # X with every NaN filled; integer codes in the categorical columns
run("adult", "general", "my-imputer", imputer=MyImputer())
🏃 Run
Datasets are downloaded from UCI on first use (Diabetes ships with scikit-learn): diabetes, shoppers, adult and letter (the results below), and wine, obesity, bike, default and news (also used in the paper).
# one method on one scenario: impute and evaluate -> runs/<dataset>/<pattern>-<mechanism>/seed<s>/<method>.json
python -m pmae.run --dataset adult --pattern general --method pmae-mix
# all experiments (4 datasets x 5 patterns x 3 seeds x 9 methods) followed by the summary tables
bash scripts/run_all.sh 0 # on GPU 0
bash scripts/run_all.sh 1 adult letter # or split the datasets across GPUs and servers,
python scripts/make_tables.py # then summarize the merged runs/
Methods are pmae-mix and pmae-trf (ours), and the baselines remasker, hyperimpute, miceforest, gain, em, knn and naive. Missing values follow one of five patterns, with a logistic model of the complete values that depends on the missing columns themselves (MNAR):
| Pattern | Columns with missing values | Observed probability per column | Structure |
|---|---|---|---|
monotone |
60% of the columns | decreasing evenly from 0.8 to 0.2 | nested: a row missing a column also misses every later one |
quasi |
all | 60% of the columns U(0.95, 0.99), the others U(0.2, 0.8) | nested, with a few exceptions |
general |
all | U(0.2, 0.8) | independent across columns |
partial-a |
60% of the columns | 0.5 | independent across columns |
partial-b |
all | 60% of the columns U(0.95, 0.99), the others U(0.2, 0.8) | independent across columns |
Partial-A and Partial-B are the Monotone and Quasi-Monotone patterns of the paper's experiments. In this release, Monotone and Quasi-Monotone are updated to the nested structure of their definitions (see Notes on this release below).
📏 Evaluation
Each imputer is fit on the train split. Imp. Acc and RMSE are computed on the held-out validation split, whose rows the imputer never sees during fitting, over the entries the pattern made missing.
- Imp. Acc (the paper's Imputation Accuracy): the mean, over the columns with missing entries, of R² for numerical columns (on a quantile-normal scale fit on the complete train split, clipped at 0) and accuracy for categorical columns.
- RMSE of the numerical entries on the same scale, min-max scaled to [0, 1].
- Utility: downstream performance of XGBoost, random forest and a linear model trained on the imputed data, relative to training on the complete data; reported as the rank of each method within a run.
These are point accuracy measures: they compare each imputed value with the true value, and do not measure whether the imputations follow the distribution of the data (their spread, or the dependence between columns).
📊 Results
Diabetes, Shoppers, Adult and Letter; the five patterns (MNAR); three seeds (×100, best in bold). Utility is the rank of each method within a run (1 = best), averaged over the runs.
Baselines: ReMasker (ICLR 2024; code), HyperImpute (ICML 2022; code), MiceForest (chained equations with LightGBM), GAIN (ICML 2018), EM (Dempster et al., 1977), KNN (Troyanskaya et al., 2001) and mean / mode imputation (Naive).
| Method | Imp. Acc ↑ | R² ↑ | Acc ↑ | RMSE ↓ | Utility (rank ↓) |
|---|---|---|---|---|---|
| PMAE-mix (ours) | 42.4 | 26.5 | 61.7 | 14.3 | 3.5 |
| PMAE-trf (ours) | 39.9 | 23.8 | 60.2 | 14.5 | 3.9 |
| ReMasker | 28.2 | 16.5 | 48.8 | 15.8 | 5.5 |
| HyperImpute | 29.8 | 17.1 | 50.6 | 15.5 | 5.0 |
| MiceForest | 30.7 | 16.9 | 51.9 | 15.7 | 4.9 |
| GAIN | 16.7 | 4.4 | 36.3 | 20.4 | 6.7 |
| EM | 27.2 | 15.6 | 45.8 | 15.7 | 5.6 |
| KNN | 28.0 | 10.8 | 49.6 | 17.3 | 4.7 |
| Naive | 18.1 | 0.2 | 42.2 | 19.0 | 5.3 |
PMAE-mix (ours) beats the strongest baseline on Imp. Acc in 58 of 60 runs (MiceForest) and on Utility in 38 of 60 runs (KNN).
Per dataset and pattern
Diabetes, Imp. Acc ↑
| Method | Monotone | Quasi-Monotone | General | Partial-A | Partial-B | Mean |
|---|---|---|---|---|---|---|
| PMAE-mix (ours) | 23.2 | 23.4 | 24.0 | 29.3 | 35.0 | 27.0 |
| PMAE-trf (ours) | 12.9 | 21.8 | 16.6 | 15.0 | 34.1 | 20.1 |
| ReMasker | 9.5 | 8.8 | 8.5 | 3.0 | 18.6 | 9.7 |
| HyperImpute | 13.7 | 16.3 | 8.6 | 14.3 | 20.7 | 14.7 |
| MiceForest | 13.3 | 24.0 | 11.8 | 22.2 | 26.3 | 19.5 |
| GAIN | 7.7 | 8.8 | 9.1 | 11.2 | 15.0 | 10.4 |
| EM | 20.2 | 26.1 | 14.8 | 26.1 | 32.6 | 24.0 |
| KNN | 17.8 | 16.2 | 5.8 | 16.2 | 25.2 | 16.2 |
| Naive | 0.0 | 1.4 | 4.2 | 0.0 | 5.1 | 2.1 |
Shoppers, Imp. Acc ↑
| Method | Monotone | Quasi-Monotone | General | Partial-A | Partial-B | Mean |
|---|---|---|---|---|---|---|
| PMAE-mix (ours) | 34.4 | 44.9 | 43.3 | 43.7 | 57.8 | 44.8 |
| PMAE-trf (ours) | 33.1 | 44.3 | 42.5 | 40.1 | 56.2 | 43.2 |
| ReMasker | 30.4 | 36.1 | 36.2 | 37.2 | 51.2 | 38.2 |
| HyperImpute | 28.3 | 37.3 | 37.3 | 38.0 | 50.0 | 38.2 |
| MiceForest | 25.2 | 35.1 | 29.4 | 32.6 | 48.9 | 34.3 |
| GAIN | 15.5 | 18.7 | 17.2 | 18.6 | 27.4 | 19.5 |
| EM | 27.8 | 34.0 | 32.7 | 29.0 | 42.9 | 33.3 |
| KNN | 29.0 | 19.7 | 18.1 | 28.9 | 40.8 | 27.3 |
| Naive | 17.7 | 21.5 | 22.5 | 17.5 | 24.7 | 20.8 |
Adult, Imp. Acc ↑
| Method | Monotone | Quasi-Monotone | General | Partial-A | Partial-B | Mean |
|---|---|---|---|---|---|---|
| PMAE-mix (ours) | 38.4 | 47.9 | 51.3 | 45.5 | 55.6 | 47.7 |
| PMAE-trf (ours) | 38.2 | 47.8 | 51.2 | 44.7 | 55.8 | 47.5 |
| ReMasker | 26.7 | 36.2 | 37.9 | 30.5 | 40.7 | 34.4 |
| HyperImpute | 27.2 | 37.2 | 33.3 | 32.1 | 46.7 | 35.3 |
| MiceForest | 30.7 | 40.4 | 39.8 | 35.2 | 49.0 | 39.0 |
| GAIN | 15.6 | 21.9 | 13.7 | 14.8 | 20.8 | 17.3 |
| EM | 17.0 | 26.6 | 28.2 | 16.5 | 28.0 | 23.3 |
| KNN | 28.5 | 24.9 | 25.4 | 26.3 | 37.2 | 28.5 |
| Naive | 19.6 | 30.9 | 31.0 | 19.6 | 30.1 | 26.3 |
Letter, Imp. Acc ↑
| Method | Monotone | Quasi-Monotone | General | Partial-A | Partial-B | Mean |
|---|---|---|---|---|---|---|
| PMAE-mix (ours) | 48.6 | 48.8 | 43.5 | 51.9 | 56.5 | 49.9 |
| PMAE-trf (ours) | 44.8 | 51.0 | 43.4 | 46.3 | 58.2 | 48.8 |
| ReMasker | 31.0 | 29.8 | 28.9 | 32.0 | 30.0 | 30.3 |
| HyperImpute | 31.0 | 34.3 | 25.0 | 25.6 | 39.7 | 31.1 |
| MiceForest | 26.9 | 29.8 | 25.5 | 31.0 | 37.3 | 30.1 |
| GAIN | 15.4 | 19.1 | 18.8 | 22.3 | 23.0 | 19.7 |
| EM | 27.6 | 27.8 | 27.9 | 29.1 | 29.6 | 28.4 |
| KNN | 45.1 | 33.3 | 21.6 | 45.1 | 54.5 | 39.9 |
| Naive | 21.9 | 23.6 | 23.6 | 22.3 | 25.2 | 23.3 |
🔁 Pipeline
- Collect the tables from UCI (Diabetes from scikit-learn).
- Split each table 60/20/20 into train, validation and test.
- Mask train and validation entries with a missing pattern; the test split and the target column stay complete.
- Encode with the observed train entries only: numerical columns are quantile-normal transformed; rare categories are merged and categories are integer encoded.
- Impute: the imputer is fit on the train split and fills the train and validation splits.
- Map the imputations back to the original columns and values, and evaluate.
Repository structure
pmae/
├── masking.py # proportional masking (Eq. 11)
├── model.py # the masked autoencoder: tokens, mixer / transformer blocks, heads, loss
├── imputer.py # PMAE: scaling, training, imputation (fit / transform)
├── run.py # one method on one scenario: build, impute, evaluate
├── evaluate.py # Imp. Acc, R², Acc, RMSE, Utility
├── data/
│ ├── datasets.py # step 1: download and clean the tables
│ ├── split.py # step 2: fixed stratified 60/20/20 split
│ ├── patterns.py # step 3: Monotone, Quasi-Monotone, General, Partial-A, Partial-B; MNAR, MAR, MCAR
│ ├── preprocess.py # step 4: encoders fit on the observed train entries
│ ├── scenario.py # steps 2-4 for one scenario, and the map back to data space
│ └── schema.py # column roles
└── baselines/
├── remasker.py # ReMasker, following the official code
├── simple.py # Naive, KNN
└── external.py # EM, GAIN, HyperImpute (hyperimpute); MiceForest (miceforest)
scripts/
├── run_all.sh # all experiments, then the summary tables
├── make_tables.py # the tables above
└── plot_overview.py # the figure above
tests/ # masking, model, data pipeline, metrics
📝 Notes on this release
The following updates raise the Imp. Acc of PMAE-mix and PMAE-trf by a few points over the previous implementation; masking, loss normalization and architectures are unchanged:
- Numerical columns are standardized and predicted by a linear head (previously min-max scaled, with a bounded head).
- Categorical columns use learned embeddings and a cross-entropy loss scaled by the column's category entropy, as in CDTD (ICLR 2025) (previously integer codes with a squared error).
Monotone and Quasi-Monotone are now nested, as in the paper's definitions; the paper's experiments drew each column independently, and those versions are kept as Partial-A and Partial-B.
📖 Citation
@inproceedings{kim2025pmae,
title = {To Predict or Not to Predict? Proportionally Masked Autoencoders for Tabular Data Imputation},
author = {Kim, Jungkyu and Lee, Kibok and Park, Taeyoung},
booktitle = {Proceedings of the AAAI Conference on Artificial Intelligence},
volume = {39},
number = {17},
pages = {17886--17894},
year = {2025},
doi = {10.1609/aaai.v39i17.33967}
}
🙏 Acknowledgements
The masked autoencoder and the ReMasker baseline follow the official ReMasker code, with transformer and MLP blocks adapted from timm (Apache-2.0). The categorical loss calibration follows CDTD (MIT). EM, GAIN and HyperImpute use hyperimpute (MIT), and MiceForest uses miceforest (MIT). The data loaders and the downstream evaluation follow AugMask.
Released under the MIT License.
Metadata
Release files for pmae 0.1.1
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 |
|---|---|---|---|---|
| pmae-0.1.1.tar.gz | 42.4 kB | Without provenance | Details for pmae-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pmae-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pmae-0.1.1-py3-none-any.whl |
Total release size: 80.6 kB
Release files / pmae-0.1.1.tar.gz
| Download URL | pmae-0.1.1.tar.gz |
|---|---|
| Size | 42.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc9d85a21089447d8a6508925c250e04f800d1b33caa7ee2246a28566f9370ef
|
|
BLAKE2b-256 checksum How to use checksums |
01c9c2afdfba26facddaea31f0d444286eb60d509d10812e107930c006b351ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pmae-0.1.1-py3-none-any.whl
| Download URL | pmae-0.1.1-py3-none-any.whl |
|---|---|
| Size | 38.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5dda6503889e678c75dc7eb957f061c9ad06cf044cedfb73629f9d9d044ebb08
|
|
BLAKE2b-256 checksum How to use checksums |
91ca21aaaaf8c97cc2f9134163ec624af346b178b5cfc28763e968875b1de868
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Security for pmae 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.