<jupyter_start><jupyter_text>作業 用 digits (3個數字即可 , dataset.load_digits(n_class=3)) 資料嘗試跑 PCA<jupyter_code>from sklearn import datasets

digits = datasets.load_digits(n_class=3)
X = digits.data
y = digits.target<jupyter_output><empty_output><jupyter_text>載入 相關套件 並 執行 PCA 實驗 ...<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
print(X.shape) #dim = 64
print(y.shape) #class = 3
from sklearn.decomposition import PCA
pca = PCA(n_components=3)
pca.fit(X)
result = pca.transform(X)
print(result.shape)
fig = plt.figure(1, figsize=(5, 5))
plt.clf()
ax = Axes3D(fig, rect=[0, 0, .95, 1], elev=48, azim=134)
plt.cla()

ax.scatter(result[:, 0], result[:, 1], result[:, 2], c=y, cmap=plt.cm.nipy_spectral,
           edgecolor='k')
plt.show()
plt.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15282791817087846, 'fraction_numerical': 0.031287605294825514, 'mean_word_length': 5.87603305785124, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '642569', 'license': 'MIT', 'n_tokens_mistral': 392, 'n_tokens_neox': 379, 'n_words': 74, 'path': 'Day_059_HW.ipynb', 'repo_name': 'semishen/ML100Days', 'size': '831'}