I am using a python package for multiple correspondence analysis on multiple categorical variable. I am studying a set geological data, here is a sample preview:
Quartz Oxides Hematite Limonite Geothite Clay Soil_Type
1 2 3 4 1 0 A
2 1 4 3 0 1 B
3 4 2 1 4 0 A
4 3 1 2 0 3 C
0 2 3 4 1 2 D
1 0 2 4 3 4 C
0 - not present, 1 - present in very small (trace) amounts, 2 - present in small amount, 3 - present in medium amount, 4- present in abundant amounts.
my code is as follow:
geology = pd.read_csv('geology_data.csv')
x = geology[['RigNumber','Quartz','Oxides','Hematite','Limonite','Geothite','Clay']].fillna(0)
y = geology[['Soil_Type']]
print 'Dimensionality Reduction'
mca_ben = mca.mca(x)
print mca_ben
mca_ind = mca.mca(x, benzecri=False)
print mca_ind
print(mca.MCA.__doc__)
However I am receiving an error stating:
Traceback (most recent call last):
File "C:\Users\root\Desktop\Data\raw data\new raw\merged wit npt\multiclass without productive\parameter propagation\New Predict\clustering-mca.py", line 33, in <module>
mca_ben = mca.mca(x, ncols=31)
File "C:\Users\root\AppData\Roaming\Python\Python27\site-packages\mca.py", line 47, in __init__
self.D_r = numpy.diag(1/numpy.sqrt(self.r))
File "C:\Python27\lib\site-packages\numpy\lib\twodim_base.py", line 302, in diag
res = zeros((n, n), v.dtype)
MemoryError
I am suspecting that mca is only limited to dichotomous dummy variables.
I also tried to transform each dummy variable into separate columns by using
x = pd.get_dummies(x)
but to no avail, I am still getting the same error.
Note that I do not want to use PCA because of obvious reasons.
I also used another python package called prince and I tried the example found in the documentation, unfortunately I am also receiving an error:
Traceback (most recent call last):
File "C:\Users\root\Desktop\Data\raw data\new raw\merged wit npt\multiclass without productive\parameter propagation\New Predict\clustering-mca.py", line 14, in <module>
mca = prince.MCA(df, n_components=-1)
File "C:\Python27\lib\site-packages\prince\mca.py", line 42, in __init__
super(MCA, self).__init__(
TypeError: super() argument 1 must be type, not classobj
Any advice?