skoot.decomposition.QRDecomposition

class skoot.decomposition.QRDecomposition(X, pivot=True)[source][source]

Perform the QR decomposition on a matrix.

Performs the QR decomposition using LINPACK, BLAS and LAPACK Fortran subroutines, and provides an interface for other useful QR utility methods.

Unlike most other classes in skoot, the QRDecomposition does not conform to the sklearn interface, and is fit immediately upon instantiation.

Parameters:

X : array-like, shape (n_samples, n_features)

The matrix to decompose. Unlike many other classes in skoot, this one does not require a Pandas frame, and can be applied directly to numpy arrays.

pivot : bool, optional (default=True)

Whether to perform pivoting. Default is True.

Attributes

qr (array-like, shape (n_samples, n_features)) The decomposed matrix
qraux (array-like, shape (n_features,)) Contains further information required to recover the orthogonal part of the decomposition.
pivot (array-like, shape (n_features,)) The pivots, if pivot was set to 1, else None
rank (int) The rank of the input matrix

Examples

The following example applies the QRDecomposition to the diabetes dataset:

>>> from sklearn.datasets import make_classification
>>> X, y = make_classification(n_samples=1000, n_features=20,
...                            n_informative=12, random_state=1)
>>> qr = QRDecomposition(X)
>>> qr.qr[:3]
array([[ 6.62984626e+01, -2.09133094e+00, -1.09276829e+00,
         5.58014214e+00, -8.32668709e+00, -1.97547759e+01,
        -6.85313166e+00, -6.42853241e+00,  5.94403138e+00,
        -2.15967470e+01, -2.35917991e-01, -5.20261414e+00,
         2.57589906e+00,  1.16805385e+01, -3.04018942e-01,
         7.90088801e-01,  3.02117704e-01, -1.09919010e+01,
         4.41783544e-01,  4.46781544e+00],
       [ 6.18367459e-02, -7.72568215e+01, -1.55131934e+00,
        -1.16888104e+01, -5.94188765e+00, -4.20310720e+01,
        -6.79982237e+00, -1.16643515e+00,  1.23441742e+01,
         5.68140358e+01,  1.48759893e+00, -3.07980793e+00,
        -1.30638396e-01, -1.40662087e+00,  4.72221164e-03,
        -2.67913340e-01,  1.08518423e+00,  6.48536112e+00,
        -3.61589065e+00, -8.54657339e+00],
       [-1.46203358e-03, -2.82718061e-03, -3.13247668e+01,
        -4.42956256e-03, -2.27949848e+00, -2.37512023e+00,
        -1.50550170e+00,  2.39909438e+00, -5.01917157e+00,
        -5.84909738e+00,  5.47610545e-01, -9.82967076e-01,
         8.36013852e-01, -3.06521652e+00, -6.12860254e-01,
        -3.57806556e-01, -1.64002608e-01,  9.76526585e-01,
         5.15293669e-01,  1.78207627e+00]])

Methods

get_R() Get the R matrix from the decomposition.
get_R_rank() Get the rank of the R matrix.
get_coef(X)
get_rank() Get the rank of the decomposition.
__init__(X, pivot=True)[source][source]

Initialize self. See help(type(self)) for accurate signature.

get_R()[source][source]

Get the R matrix from the decomposition.

Returns:

r : np.ndarray

The R portion of the decomposed matrix.

get_R_rank()[source][source]

Get the rank of the R matrix.

Returns:

rank : int

The rank of the R matrix

get_rank()[source][source]

Get the rank of the decomposition.

Returns:

self.rank : int

The rank of the decomposition