if knn_dist != "precomputed" and ndim < data.shape[1]:
if verbose:
print("Calculating PCA...")
start = time.time()
if sparse.issparse(data):
_, _, VT = randomized_svd(data, ndim,
random_state=random_state)
data = data.dot(VT.T)
else:
pca = PCA(ndim, svd_solver="randomized",
random_state=random_state)
data = pca.fit_transform(data)
if verbose:
print("PCA complete in {:.2f} seconds".format(
time.time() - start))
if verbose:
start = time.time()
print("Calculating KNN...")
// kernel includes self as connection but not in k