'Apply the dimension reduction learned on the train data.
Parameters
X : array-like, shape = [n_samples, n_features]
Training vectors, where n_samples is the number of samples and
n_features is the number of predictors.
Y : array-like, shape = [n_samples, n_targets]
Target vectors, where n_samples is the number of samples and
n_targets is the number of response variables.
copy : boolean, default True
Whether to copy X and Y, or perform in-place normalization.
Returns
x_scores if Y is not given, (x_scores, y_scores) otherwise.'

def transform(self, X, Y=None, copy=True):

    check_is_fitted(self, 'x_mean_')
    X = check_array(X, copy=copy, dtype=FLOAT_DTYPES)
    X -= self.x_mean_
    X /= self.x_std_
    x_scores = np.dot(X, self.x_rotations_)
    if (Y is not None):
        Y = check_array(Y, ensure_2d=False, copy=copy, dtype=FLOAT_DTYPES)
        if (Y.ndim == 1):
            Y = Y.reshape((-1), 1)
        Y -= self.y_mean_
        Y /= self.y_std_
        y_scores = np.dot(Y, self.y_rotations_)
        return (x_scores, y_scores)
    return x_scores
