'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.'

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

    check_is_fitted(self, 'x_mean_')
    X = check_array(X, dtype=np.float64)
    Xr = ((X - self.x_mean_) / self.x_std_)
    x_scores = np.dot(Xr, self.x_weights_)
    if (Y is not None):
        if (Y.ndim == 1):
            Y = Y.reshape((-1), 1)
        Yr = ((Y - self.y_mean_) / self.y_std_)
        y_scores = np.dot(Yr, self.y_weights_)
        return (x_scores, y_scores)
    return x_scores
