def __init__(self, hash_name, projection_count, training_set):
super(PCABinaryProjections, self).__init__(hash_name)<EOL>self.projection_count = projection_count<EOL>if not training_set is None:<EOL><INDENT>training_set = numpy_array_from_list_or_numpy_array(training_set)<EOL>self.dim = training_set.shape[<NUM_LIT:0>]<EOL>training_set_t = numpy.transpose(training_set)<EOL>(eigenvalues, eigenvectors) = perform_pca(training_set_t)<EOL>largest_eigenvalue_indices = numpy.flipud(<EOL>scipy.argsort(eigenvalues))[:projection_count]<EOL>self.components = numpy.zeros((self.dim,<EOL>len(largest_eigenvalue_indices)))<EOL>for index in range(len(largest_eigenvalue_indices)):<EOL><INDENT>self.components[:, index] =eigenvectors[:, largest_eigenvalue_indices[index]]<EOL><DEDENT>self.components = numpy.transpose(self.components)<EOL><DEDENT>else:<EOL><INDENT>self.dim = None<EOL>self.components = None<EOL><DEDENT>self.components_csr = None<EOL>
Computes principal components for training vector set. Uses
first projection_count principal components for projections.

Training set must be either a numpy matrix or a list of
numpy vectors.