Skip to main content

DDLK: Deep direct likelihood knockoffs

This package implements DDLK, a method for variable selection with explicit control of the false discovery rate. Install with:

pip install ddlk

Controlled variable selection with DDLK

Suppose you have a set of features and a response. DDLK identifies the features most predictive of the response at a pre-specified false discovery rate (FDR) threshold. For example, if you choose an FDR of 20%, DDLK can guarantee that no more than 20% of the selected features will be unimportant. To learn more about how it works, check out our paper.

Running DDLK

Variable selection with DDLK involves three stages:

  1. Fit a joint distribution to model features
  2. Fit a knockoff generator
  3. Sample knockoffs and apply knockoff filter to select variables at a pre-specified FDR

To see a complete working example, check our synthetic data example, used to generate the gif above. Below is an exceprt of how to run DDLK.

Fitting a joint distribution

This implementation of DDLK uses the fast and easy PyTorch Lightning framework to fit q_joint:

# initialize data
x, y = ...
# put your data in standard PyTorch format
trainloader = ...
# initialize joint distribution model with mean and std of data
((X_mu, ), (X_sigma, )) = utils.get_two_moments(trainloader)
hparams = argparse.Namespace(X_mu=X_mu, X_sigma=X_sigma)
q_joint = mdn.MDNJoint(hparams)
# create and fit a PyTorch Lightning trainer
trainer = pl.Trainer()
trainer.fit(q_joint, train_dataloader=trainloader)

Fitting a knockoff generator

# initialize and fit a DDLK knockoff generator
q_knockoff = ddlk.DDLK(hparams, q_joint=q_joint)
trainer = pl.Trainer()
trainer.fit(q_knockoff, train_dataloader=trainloader)

Variable selection

Using the knockoff generator, we sample knockoffs, and run a Holdout Randomization Test:

xTr_tilde = q_knockoff.sample(xTr)
knockoff_test = hrt.HRT_Knockoffs()
knockoff_test.fit(xTr, yTr, xTr_tilde)

Citing this code

If you use this code, please cite the following paper (available here):

Deep Direct Likelihood Knockoffs
M. Sudarshan, W. Tansey, R. Ranganath
arXiv preprint arXiv:2007.15835

Bibtex entry:

@misc{sudarshan2020deep,
    title={Deep Direct Likelihood Knockoffs},
    author={Mukund Sudarshan and Wesley Tansey and Rajesh Ranganath},
    year={2020},
    eprint={2007.15835},
    archivePrefix={arXiv},
    primaryClass={stat.ML}
}

Release files for ddlk 0.0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ddlk 0.0.0.2
File Size Uploaded
ddlk-0.0.0.2.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ddlk 0.0.0.2
File Interpreter ABI Platform
ddlk-0.0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / ddlk-0.0.0.2.tar.gz

Download URL ddlk-0.0.0.2.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5faaebadca9b5bf18fcd7785bad5aee6324f214973c1793ff1f67ec52185ddb7
BLAKE2b-256 checksum
How to use checksums
228fe9506e60899801e0034390a9e0dc7739f45ed00c794e4fdb456592c13553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / ddlk-0.0.0.2-py3-none-any.whl

Download URL ddlk-0.0.0.2-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6611a2ede88fc6bec3fde8f8337f80c0689328ebdd3b62509d688b513286333e
BLAKE2b-256 checksum
How to use checksums
100f0337270d95d5b3c4bb91fa324b75fa51da1552781a76a544d0baa57cf452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page