'Transform X.
This is implemented by linking the points X into the graph of geodesic
distances of the training data. First the `n_neighbors` nearest
neighbors of X are found in the training data, and from these the
shortest geodesic distances from each point in X to each point in
the training data are computed in order to construct the kernel.
The embedding of X is the projection of this kernel onto the
embedding vectors of the training set.
Parameters
X : array-like, shape (n_samples, n_features)
Returns
X_new : array-like, shape (n_samples, n_components)'

def transform(self, X):

    X = check_array(X)
    (distances, indices) = self.nbrs_.kneighbors(X, return_distance=True)
    G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
    for i in range(X.shape[0]):
        G_X[i] = np.min((self.dist_matrix_[indices[i]] + distances[i][:, None]), 0)
    G_X **= 2
    G_X *= (-0.5)
    return self.kernel_pca_.transform(G_X)
