I want to combine n number of feature vectors each with m amount of features into a single feature vector with the same m amount of features. The single vector's feature values are suppose to provide some idea about the variation of each feature among the n number of feature vectors. When I use PCA for this and define (n_components=1) I get a single feature vector with m number of values. But I am not sure how they are being produced or the values gives the correct meaning that I am expecting. Is the provided code gives the expected output that I am expecting? If not how can I use PCA for this requirement ?
vector = [[1,2,3], [3,4,5], [5,6,1], [5,3,1], [7,8,9], [9,4,1]]
pca = PCA(n_components=1)
pca.fit(vector)
combined_vector = pca.components_[0]
print(combined_vector)
array([0.33044829, 0.52192279, 0.78638446])
PCA is used to transform your feature space into lower dimensional space. In your example you start with m features. PCA receives as input 6 examples, where every example if feature vector with 3 features. By doing this
You reduce your m dimensional space to 1 dimensional space and returning the direction of maximum variance in the data.