KnockoffSampler

class knockpy.knockoffs.KnockoffSampler[source]

Bases: object

Base class for sampling knockoffs.

Methods

check_PSD_condition(Sigma, S)

Checks that the feature-knockoff cov matrix is PSD.

check_xk_validity(X, Xk[, testname, alpha])

Runs a variety of KS tests on X and Xk to (informally) check that Xk are valid knockoffs for X.

fetch_S()

Fetches knockoff S-matrix.

many_ks_tests(sample1s, sample2s)

Samples1s, Sample2s = list of arrays Gets p values by running ks tests and then does a multiple testing correction.

sample_knockoffs

Methods Summary

check_PSD_condition(Sigma, S)

Checks that the feature-knockoff cov matrix is PSD.

check_xk_validity(X, Xk[, testname, alpha])

Runs a variety of KS tests on X and Xk to (informally) check that Xk are valid knockoffs for X.

fetch_S()

Fetches knockoff S-matrix.

many_ks_tests(sample1s, sample2s)

Samples1s, Sample2s = list of arrays Gets p values by running ks tests and then does a multiple testing correction.

sample_knockoffs()

Methods Documentation

check_PSD_condition(Sigma, S)[source]

Checks that the feature-knockoff cov matrix is PSD.

Parameters
Sigmanp.ndarray

(p, p)-shaped covariance matrix of the features. If None, this is estimated using the shrinkage option. This is ignored for fixed-X knockoffs.

Snp.ndarray

the (p, p)-shaped knockoff S-matrix used to generate knockoffs.

Raises
Raises an error if S is not PSD or 2 Sigma - S is not PSD.
check_xk_validity(X, Xk, testname='', alpha=0.001)[source]

Runs a variety of KS tests on X and Xk to (informally) check that Xk are valid knockoffs for X. Uses the BHQ adjustment for multiple testing.

Parameters
Xnp.ndarray

the (n, p)-shaped design

Xknp.ndarray

the (n, p)-shaped matrix of knockoffs

testnamestr

a testname that shows up in the error

alphafloat

The significance level. Defaults to 0.001

fetch_S()[source]

Fetches knockoff S-matrix.

many_ks_tests(sample1s, sample2s)[source]

Samples1s, Sample2s = list of arrays Gets p values by running ks tests and then does a multiple testing correction.

sample_knockoffs()[source]