MaxHalford / prince

:crown: Multivariate exploratory data analysis in Python — PCA, CA, MCA, MFA, FAMD, GPA
https://maxhalford.github.io/prince
MIT License
1.26k stars 182 forks source link

Bug in FAMD transform() #169

Open luismavs opened 11 months ago

luismavs commented 11 months ago

Hi,

I am not able to transform FAMD on "new" data.

Using version 0.13.0.

Please see the following code:

import pandas as pd
from prince import MCA, PCA, FAMD
df = pd.DataFrame({'var1':['c', 'a', 'b','c'], 'var2':['x','y','y','z'],'var2': [0.,10.,30.4,0.]})

famd = FAMD(n_components=2)
famd.fit(df[:3])
print(famd.transform(df[0:3]))
print(famd.transform(df[0:2]))
print(famd.transform(df[3:]))

I get the output:

component         0         1
0         -1.303760 -0.658334
1         -0.335621  0.981047
2          1.639381 -0.322713
component   0   1
0         NaN NaN
1         NaN NaN
component   0   1
3         NaN NaN

So FAMD is able to transform the training data itself, but NOT a selection of rows from it, or a new row.

Thanks!

MaxHalford commented 11 months ago

Yep that isn't supported yet. I'm aware of the issue.