<jupyter_start><jupyter_text>PCA TestPrincipal component analysis (PCA) is the linear dimensionality reduction using Singular Value Decomposition (SVD) of the data to project it to a lower dimensional space. In this case, we are projecting an 11-dimensional matrix into 2D.  Import Dependencies<jupyter_code>import numpy as np
import matplotlib.pyplot as plt

from sklearn import decomposition
from sklearn import datasets

import csv
%run 'preprocessor.ipynb' #our own preprocessor functions<jupyter_output><empty_output><jupyter_text>Prepare Dataset<jupyter_code>with open('data_w1w4.csv', 'r') as f:
      reader = csv.reader(f)
      data = list(reader)
    
matrix = obtain_data_matrix(data)
samples = len(matrix)

print("Number of samples: " + str(samples))
print("First entry: " + str(matrix[0]))<jupyter_output>Number of samples: 176
First entry: [[2680 1 0 0 0 0 0 0 4.9481 72 5 0]]<jupyter_text>Prepare the plot<jupyter_code>fig = plt.figure(1, figsize=(10, 6))
plt.clf()<jupyter_output><empty_output><jupyter_text>Do PCA<jupyter_code>plt.cla()
pca = decomposition.PCA(n_components=2)
pca.fit(matrix)
X = pca.transform(matrix)<jupyter_output><empty_output><jupyter_text>Plot the Data<jupyter_code>plt.scatter(X[:, 0], X[:, 1], edgecolor='k')

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1136890951276102, 'fraction_numerical': 0.027842227378190254, 'mean_word_length': 6.748502994011976, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '421041', 'license': 'MIT', 'n_tokens_mistral': 492, 'n_tokens_neox': 456, 'n_words': 118, 'path': 'PCA Test.ipynb', 'repo_name': 'tlkh/Generating-Inference-from-3D-Printing-Jobs', 'size': '1293'}