Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Jim-Holmstroem/d3fb39c6a30038cbdeba19c6e1d68699 to your computer and use it in GitHub Desktop.
Save Jim-Holmstroem/d3fb39c6a30038cbdeba19c6e1d68699 to your computer and use it in GitHub Desktop.
from time import time
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn.datasets import load_digits
from sklearn.decomposition import PCA
from sklearn.preprocessing import scale
digits = load_digits()
data = scale(digits.data)
n_samples, n_features = data.shape
n_digits = len(np.unique(digits.target))
sample_size = 300
pca = PCA(n_components=n_digits).fit(data)
output = pca.predict(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment