<commit_before>import numpy as np

class PCA(DimensionReducer):

    def __init__(self, n_component=2):
        self.n_component = n_component

    def reduce(self, data):
        cov_matrix = np.cov(data)
        eig_values, eig_vectors = cov_matrix.linalg.eig(cov_matrix)
        sorted_eig_indices = eig_values.argsort()[::-1]
        sorted_eig_vectors = eig_vectors[::sorted_eig_indices]
        return np.dot(data, sorted_eig_vectors[:self.n_components])<commit_msg>Corrected PCA<commit_after>import numpy as np

class PCA(DimensionReducer):

    def __init__(self, n_component=2):
        self.n_component = n_component
        self.eig_vectors = None

    def reduce(self, data):
        # Estimate the covariance matrix
        mean = np.mean(data, axis=0)
        centered_data = data - mean
        scatter_matrix = np.dot(centered_data.T, centered_data)

        # Find the eigenvectors with maximum eigenvalue
        eig_values, eig_vectors = np.linalg.eig(scatter_matrix)
        sorted_eig_indices = eig_values.argsort()[::-1]
        sorted_eig_vectors = eig_vectors[:,sorted_eig_indices]
        self.eig_vectors = sorted_eig_vectors[:,range(self.n_components)]

        # Matrix multiple the eigenvector with the data
        return np.dot(centered_data, self.eig_vectors)
{'fraction_non_alphanumeric': 0.09217660728117738, 'fraction_numerical': 0.0038729666924864447, 'mean_word_length': 3.364864864864865, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '5883562', 'n_tokens_mistral': 440, 'n_tokens_neox': 418, 'n_words': 80}