How to perform Factor Analysis of Mixed Data (FAMD) on the train and test datasets?
Generally, to apply sklearn PCA the following code is used:
pca=PCA(n_components=30).fit(X_train)
PC_train=pca.transform(X_train)
PC_test=pca.transform(X_test)
However, when I use the prince package the .transform()
cannot be applied to the test set. It gives value error as shown below?
from prince import FAMD
famd = FAMD().fit(X_train)
PC_train=famd.transform(X_train)
PC_test=famd.transform(X_test)
FAMD has to be fitted (using
.fit()
) on the data and then thefamd.transform()
can be applied on that same data. You should use: