'Apply dimensionality reduction on X.
X is projected on the first principal components previous extracted
from a training set.
Parameters
X : array-like, shape (n_samples, n_features)
New data, where n_samples in the number of samples
and n_features is the number of features.
Returns
X_new : array-like, shape (n_samples, n_components)'

def transform(self, X):

    check_is_fitted(self, 'mean_')
    X = check_array(X)
    if (self.mean_ is not None):
        X = (X - self.mean_)
    X = np.dot(X, self.components_.T)
    return X
