SlicedInverseRegression

class SlicedInverseRegression(*args)

Sliced Inverse Regression algorithm.

Warning

This class is experimental and likely to be modified in future releases. To use it, import the openturns.experimental submodule.

Sliced Inverse Regression (SIR, [li1991]) is a dimension reduction technique. It describes a low-dimensional linear subspace that captures all the necessary information a high-dimensional set of predictors holds about a response variable.

It assumes the following regression model:

Y = f(\Tr{\vect{\beta}} \vect{X}, \varepsilon)

where the response variable Y is univariate, the regressor \vect{X} is \inputDim-dimensional the vector \vect{\beta} represents the EDR directions and \varepsilon is independent of X.

The algorithm proceeds as follows:

  1. Standardize the data: Transform the predictor variables X so they have a mean of zero and an identity covariance matrix.

  2. Slice the response variable: Sort your data by the values of the response variable Y. Then, divide the sorted data into H distinct, equally sized intervals or “slices”.

  3. Calculate slice means: Within each slice, compute the average of the standardized predictor variables X.

  4. Apply Principal Component Analysis (PCA): Perform an eigen-decomposition or PCA on the covariance matrix of these sliced means.

Detailed steps consist in:

  1. Sort the output Y and divide it into H slices of equal size

  2. Center the input sample: \overline{\vect{X}} = \frac{1}{\sampleSize}\sum_{i=1}^\sampleSize \vect{X}_i

  3. Compute the QR decomposition of the centered input matrix: \vect{X} = \mat{Q} \mat{R}

  4. Standardize \mat{Z} = \sqrt{\sampleSize} \mat{Q}

  5. For each slice h, compute the weighted mean: \overline{\mat{Z}}_h = \sqrt{\sampleSize_h} \cdot \text{mean}(\mat{Z}^{(h)})

  6. Compute the singular value decomposition of the slice-mean matrix: \overline{\mat{Z}} = \mat{U} \mat{\Sigma} \Tr{\mat{V}}

  7. The right singular vectors \vect{V}_k (columns of \mat{V}) are the eigenvectors of \Tr{\overline{\mat{Z}}} \overline{\mat{Z}} with eigenvalues \lambda_k = \sigma_k^2 / \sampleSize

  8. Back-transform the eigenvectors to the original space: \vect{\alpha}_k = \sqrt{\sampleSize} \mat{R}^{-1} \vect{V}_k

  9. Keep only the first k directions according to \texttt{nbModes}

  10. Normalize the directions: \hat{\vect{\alpha}}_k = \vect{\alpha}_k / \|\vect{\alpha}_k\|

The transformation maps an input vector \vect{x} to its coordinates in the EDR basis:

f(\vect{x}) = \Tr{\hat{\vect{\alpha}}} (\vect{x} - \overline{\vect{X}})

Parameters:
XSample

Input sample

YSample

Output, supervision sample

sliceNumberint, optional

Number of slices, defaults to ResourceMap entry SlicedInverseRegression-DefaultSliceNumber

Methods

getClassName()

Accessor to the object's name.

getName()

Accessor to the object's name.

getNbModes()

Accessor to the number of EDR directions.

getResult()

Accessor to the result.

getSliceNumber()

Accessor to the number of slices.

hasName()

Test if the object is named.

run()

Run the algorithm.

setName(name)

Accessor to the object's name.

setNbModes(nbModes)

Accessor to the number of EDR directions.

setSliceNumber(sliceNumber)

Accessor to the number of slices.

Examples

>>> import openturns as ot
>>> import openturns.experimental as otexp
>>> N = 100
>>> X = ot.Normal([0.0] * 2, [0.1] * 2).getSample(N)
>>> X += [[i / (N - 1), 2 * i / (N - 1)] for i in range(N)]
>>> # X is centered internally by the SIR algorithm
>>> f = ot.SymbolicFunction(['x1', 'x2'], ['4*(x1+2*x2)+2'])
>>> Y = f(X) + ot.Normal(0.0, 0.2).getSample(N)
>>> algo = otexp.SlicedInverseRegression(X, Y)
>>> algo.run()
>>> transformation = algo.getResult().getTransformation()
__init__(*args)
getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getNbModes()

Accessor to the number of EDR directions.

Returns:
nbModesint

Number of EDR directions retained.

getResult()

Accessor to the result.

Returns:
resultSlicedInverseRegressionResult

Result class

getSliceNumber()

Accessor to the number of slices.

Returns:
sliceNumberint

Number of slices

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

run()

Run the algorithm.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

setNbModes(nbModes)

Accessor to the number of EDR directions.

Parameters:
nbModesint

Number of EDR directions retained.

setSliceNumber(sliceNumber)

Accessor to the number of slices.

Parameters:
sliceNumberint

Number of slices

Examples using the class

Sliced inverse regression

Sliced inverse regression