Beginner here. I’m trying to calculate a state’s infrastrucure index using different variables and I applied PCA.
At first I did a dot product of original data and the principal components.
pca = PCA(2).fit(ind_scaled)
ind_pca = pd.DataFrame(pca.components_)
pca_data = pd.DataFrame((np.dot(ind_scaled, pca.components_.T)).sum(axis=1))
index = pd.DataFrame()
index["States"] = states
index["Index"] = pca_data
Later I tried to use fit_transform
pca = PCA(2).fit(ind_scaled)
ind_pca = pca.transform(ind_scaled)
index = pd.DataFrame()
index["States"] = states
index["Index"] = ind_pca.sum(axis=1)
I got different answers for both. I’m not exactly sure how either results are different. Any kind of help is appreciated. Thank you
New contributor
Shriya Desikan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.