Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pca.inverse_transform in sklearn

after fitting my data into X = my data

pca = PCA(n_components=1)
pca.fit(X)
X_pca = pca.fit_transform(X)

now X_pca has one dimension.

When I perform inverse transformation by definition isn't it supposed to return to original data, that is X, 2-D array?

when I do

X_ori = pca.inverse_transform(X_pca)

I get same dimension however different numbers.

Also if I plot both X and X_ori they are different.

like image 830
haneulkim Avatar asked Apr 05 '19 10:04

haneulkim


1 Answers

When I perform inverse transformation by definition isn't it supposed to return to original data

No, you can only expect this if the number of components you specify is the same as the dimensionality of the input data. For any n_components less than this, you will get different numbers than the original dataset after applying the inverse PCA transformation: the following diagrams give an illustration in two dimensions.

enter image description here

like image 199
butterflyknife Avatar answered Sep 17 '22 17:09

butterflyknife