Skip to main content

Add your description here

Project description

3D-MICE

Implementation of 3D-MICE (3-Dimensional Multiple Imputation with Chained Equations) using only scikit-learn.

Based on: Luo et al. (2017). 3D-MICE: integration of cross-sectional and longitudinal imputation for multi-analyte longitudinal clinical data. JAMIA.

Installation

uv sync

Usage

Run Comparison Experiment

# Full test set
uv run python experiments/compare_imputers.py

# Quick test with limited samples
uv run python experiments/compare_imputers.py --max-samples 100

Use as Library

from src.imputers.mice_3d import MICE3D
from src.imputers.locf import LOCFImputer
from src.imputers.median import MedianImputer

# 3D-MICE imputation
imputer = MICE3D(mice_max_iter=10, random_state=42)
X_imputed = imputer.fit_transform(X)  # X shape: (n_samples, n_timesteps, n_features)

# Baseline imputers
locf = LOCFImputer()
median = MedianImputer()

Results on PhysioNet2012

Method MAE ↓ RMSE ↓ MRE ↓
3D-MICE 12.36 60.73 0.169
LOCF 13.58 58.71 0.186
Median 19.42 78.55 0.265

3D-MICE outperforms LOCF by 8.9% and Median by 36.3% on MAE.

Benchmarking with BenchPOTS

Install dev dependencies to access benchmarking datasets:

uv sync --dev

Load PhysioNet2012 Dataset

from benchpots.datasets import preprocess_physionet2012

# Load with artificial missing pattern for evaluation
data = preprocess_physionet2012(
    subset="all",       # 'all', 'set-a', 'set-b', or 'set-c'
    rate=0.1,           # 10% additional missing rate
    pattern="point",    # 'point', 'subseq', or 'block'
)

# Data splits
train_X = data["train_X"]              # Training data with missing values
train_X_ori = data["train_X_ori"]      # Ground truth
train_mask = data["train_indicating_mask"]  # Mask for artificially masked values

Run Benchmark

from src.imputers.mice_3d import MICE3D
from src.evaluation import evaluate_imputation

imputer = MICE3D(random_state=42)
X_imputed = imputer.fit_transform(data["test_X"])

metrics = evaluate_imputation(
    X_imputed, 
    data["test_X_ori"], 
    data["test_indicating_mask"]
)
print(f"MAE: {metrics['MAE']:.4f}, RMSE: {metrics['RMSE']:.4f}")

Other Datasets

BenchPOTS supports many time series datasets:

from benchpots.datasets import preprocess_physionet2019  # Sepsis prediction
from benchpots.datasets import preprocess_beijing_multisite_airquality

See BenchPOTS documentation for full dataset list.

Algorithm

3D-MICE combines:

  1. Cross-sectional MICE (sklearn.impute.IterativeImputer): Captures feature correlations at each timestep
  2. Longitudinal GP (sklearn.gaussian_process.GaussianProcessRegressor): Captures temporal patterns
  3. Variance-weighted combination: Blends both estimates

Citation

@article{luo20173d,
  title={3D-MICE: integration of cross-sectional and longitudinal imputation for multi-analyte longitudinal clinical data},
  author={Luo, Yuan and Szolovits, Peter and Dighe, Anand S and Baron, Jason M},
  journal={Journal of the American Medical Informatics Association},
  volume={25},
  number={6},
  pages={645--653},
  year={2017},
  publisher={Oxford University Press}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mice3d-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mice3d-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file mice3d-0.1.0.tar.gz.

File metadata

  • Download URL: mice3d-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.5

File hashes

Hashes for mice3d-0.1.0.tar.gz
Algorithm Hash digest
SHA256 176a19854cd04ed44f890f361e50131feeb275d61c3d02be4a056d66a54240dc
MD5 07c0cfb571957c3579d1d47790a01906
BLAKE2b-256 86df29571a97a33160c11508c84e0c98fdbe402276df345e44f750ee6945d60e

See more details on using hashes here.

File details

Details for the file mice3d-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mice3d-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.5

File hashes

Hashes for mice3d-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a9400e75d0d483ba38840527c91591088830f28f589ceb4b243ad1c54fe0d1d
MD5 cbe0aac133338600bebfdb3f0dc4eeca
BLAKE2b-256 2ae1db7b29dd95c40a9e23699ff61c92c3bcfd63dd9752ce11244bf29309cf18

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page