I hope this helps you . GridSearchCV is capable of doing cross-validation of unsupervised learning (without a y) as can be seen

code :

```
...
y : array-like, shape = [n_samples] or [n_samples, n_output], optional
Target relative to X for classification or regression;
None for unsupervised learning
...
```

```
....
neg_mean_squared_error_scorer = make_scorer(mean_squared_error,
greater_is_better=False)
....
```

```
from sklearn.metrics import mean_squared_error
def my_scorer(estimator, X, y=None):
X_reduced = estimator.transform(X)
X_preimage = estimator.inverse_transform(X_reduced)
return -1 * mean_squared_error(X, X_preimage)
```

```
param_grid = [{
"gamma": np.linspace(0.03, 0.05, 10),
"kernel": ["rbf", "sigmoid", "linear", "poly"]
}]
kpca=KernelPCA(fit_inverse_transform=True, n_jobs=-1)
grid_search = GridSearchCV(kpca, param_grid, cv=3, scoring=my_scorer)
grid_search.fit(X)
```