APIlink

Some simple/useful examples are available at Usage, using the following API:

Methods covered:

  • Residualize

  • Augment

  • DummyDeconfounding

Library exceptions:

  • ConfoundsException


code class base.Residualize(model='linear')[source]link

Bases: base.BaseDeconfound

Deconfounding estimator class that residualizes the input features by subtracting the contributions from the confound variables

Example methods: Linear, Kernel Ridge, Gaussian Process Regression etc

codemethod fit(self, X, y=None)[source]link

Fits the residualizing model (estimates the contributions of confounding variables (y) to the given [training] feature set X. Variable names X, y had to be used to pass sklearn conventions. y here refers to the confound variables, and NOT the target. See examples in docs!

Parameters
X{array-like, sparse matrix}, shape (n_samples, n_features)

The training input samples.

yndarray

Array of covariates, shape (n_samples, n_covariates) This does not refer to target as is typical in scikit-learn.

Returns
selfobject

Returns self

codemethod transform(self, X, y=None)[source]link

Transforms the given feature set by residualizing the [test] features by subtracting the contributions of their confounding variables.

Variable names X, y had to be used to pass scikit-learn conventions. y here refers to the confound variables for the [test] to be transformed, and NOT their target values. See examples in docs!

Parameters
X{array-like, sparse matrix}, shape (n_samples, n_features)

The training input samples.

yndarray

Array of covariates, shape (n_samples, n_covariates) This does not refer to target as is typical in scikit-learn.

Returns
selfobject

Returns self

code class base.Augment[source]link

Bases: base.BaseDeconfound

Deconfounding estimator class that simply augments/concatenates the confounding variables to input features prior to prediction.

codemethod fit(self, X, y=None)[source]link

Learns the dimensionality of confounding variables to be augmented.

Variable names X, y had to be used to pass sklearn conventions. y here refers to the confound variables, and NOT the target. See examples in docs!

Parameters
X{array-like, sparse matrix}, shape (n_samples, n_features)

The training input samples.

yndarray

Array of covariates, shape (n_samples, n_covariates) This does not refer to target as is typical in scikit-learn.

Returns
selfobject

Returns self

codemethod transform(self, X, y=None)[source]link

Transforms the given feature set by augmenting the confounding variables.

Variable names X, y had to be used to pass sklearn conventions. y here refers to the confound variables for the [test] to be transformed, and NOT their target values. See examples in docs!

Parameters
X{array-like, sparse matrix}, shape (n_samples, n_features)

The training input samples.

yndarray

Array of covariates, shape (n_samples, n_covariates) This does not refer to target as is typical in scikit-learn.

Returns
selfobject

Returns self

code class base.DummyDeconfounding[source]link

Bases: base.BaseDeconfound

A do-nothing dummy method, to serve as a reference for methodological comparisons

codemethod fit(self, X, y=None)[source]link

A do-nothing fit method.

Parameters
X{array-like, sparse matrix}, shape (n_samples, n_features)

The training input samples.

yndarray

Array of covariates, shape (n_samples, n_covariates)

Returns
selfobject

Returns self.

codemethod transform(self, X, y=None)[source]link

A do-nothing transform method.

Parameters
X{array-like, sparse-matrix}, shape (n_samples, n_features)

The input samples.

yndarray

Array of covariates, shape (n_samples, n_covariates)

Returns
X_transformedarray, shape (n_samples, n_features)

Same as the input X.

exception base.ConfoundsException[source]link

Bases: BaseException

Custom exception to indicate confounds-library specific issues.