HP_17
HP_17

Reputation: 203

Using Prince library for MCA and FAMD in python

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)

enter image description here

Upvotes: 2

Views: 7971

Answers (1)

Avigyan Sinha
Avigyan Sinha

Reputation: 11

FAMD has to be fitted (using .fit()) on the data and then the famd.transform() can be applied on that same data. You should use:

famd = FAMD().fit(X_test)
PC_test=famd.transform(X_test)

Upvotes: 1

Related Questions