API and modules

pythonsi:

feature_selection

Feature selection methods with selective inference.

domain_adaptation

Domain adaptation methods with selective inference.

test_statistics

Test statistic definitions for selective inference.

Global pythonsi functions and classes:

class pythonsi.Data(parent: any = None)[source]

Data object (node) which is used to store data and parametrized data.

Parameters:

parent (any, optional) – Parent node to compute data from. If None, data must be set directly.

data

The observed data stored in this node

Type:

array-like or None

parent

Parent node for computation

Type:

any or None

a

Parametrized intercept

Type:

array-like or None

b

Parametrized coefficient for inference

Type:

array-like or None

inference_data

Data used in the inference process

Type:

array-like or None

inference(z: float)[source]

Perform inference computation with given scalar z.

Computes the linear relationship \(\mathbf{data} = \mathbf{a} + \mathbf{b} \cdot z\) and retrieves the feasible interval from parent if available.

Parameters:

z (float) – Parameter value for inference computation

Returns:

  • inference_data (array-like, shape (d,)) – Computed inference data

  • a (array-like, shape (d,)) – Parametrized intercept

  • b (array-like, shape (d,)) – Parametrized coefficient

  • interval (list of float) – Feasible interval from parent or [-inf, inf] if no parent

parametrize(a: ndarray[tuple[Any, ...], dtype[floating]] = None, b: ndarray[tuple[Any, ...], dtype[floating]] = None, data: ndarray[tuple[Any, ...], dtype[floating]] = None)[source]

Set parameters for selective inference process.

Parameters:
  • a (array-like, shape (d,), optional) – Linear intercept parameter

  • b (array-like, shape (d,), optional) – Linear coefficient parameter

  • data (array-like, shape (n, d), optional) – Inference data to store

update(data: ndarray[tuple[Any, ...], dtype[floating]])[source]

Update the observed data stored in this node.

Parameters:

data (array-like, shape (n, d)) – New data to store in the node

class pythonsi.Pipeline(inputs: List[Data], output: Data, test_statistic: any)[source]

Selective inference for Feature selection pipeline.

Parameters:
  • inputs (list of Data) – Input datas for the pipeline

  • output (Data) – Output data for the pipeline

  • test_statistic (object) – Chosen test statistic for inference

input_nodes

Input data nodes

Type:

list of Data

output_node

Output data node

Type:

Data

test_statistic

Test statistic computation object

Type:

object

inference(output_id: int, covariances: List[ndarray[tuple[Any, ...], dtype[floating]]], output: ndarray[tuple[Any, ...], dtype[floating]]) float[source]

Perform selective inference for a single specific data based on the chosen hypothesis and test statistic.

For example, testing if a specific selected feature has a non-zero coefficient

Parameters:
  • feature_id (int) – Index of the feature to test (within selected features)

  • covariances (list of array-like) – Covariance matrices for noise in each input

  • output (array-like, shape (k,)) – Array of selected feature indices

Returns:

p_value – Selective p-value for the data

Return type:

float