'Least Squares projection of the data onto the sparse components.
To avoid instability issues in case the system is under-determined,
regularization can be applied (Ridge regression) via the
`ridge_alpha` parameter.
Note that Sparse PCA components orthogonality is not enforced as in PCA
hence one cannot use a simple linear projection.
Parameters
X : array of shape (n_samples, n_features)
Test data to be transformed, must have the same number of
features as the data used to train the model.
ridge_alpha : float, default: 0.01
Amount of ridge shrinkage to apply in order to improve
conditioning.
.. deprecated:: 0.19
This parameter will be removed in 0.21.
Specify ``ridge_alpha`` in the ``SparsePCA`` constructor.
Returns
X_new array, shape (n_samples, n_components)
Transformed data.'

def transform(self, X, ridge_alpha='deprecated'):

    check_is_fitted(self, 'components_')
    X = check_array(X)
    if (ridge_alpha != 'deprecated'):
        warnings.warn('The    ridge_alpha    parameter    on    transform()    is    deprecated    since    0.19    and    will    be    removed    in    0.21.    Specify    ridge_alpha    in    the    SparsePCA    constructor.', DeprecationWarning)
        if (ridge_alpha is None):
            ridge_alpha = self.ridge_alpha
    else:
        ridge_alpha = self.ridge_alpha
    U = ridge_regression(self.components_.T, X.T, ridge_alpha, solver='cholesky')
    s = np.sqrt((U ** 2).sum(axis=0))
    s[(s == 0)] = 1
    U /= s
    return U
