You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am using MCA and apply it on training data and then after fitting the model on training data I would like to apply the model on my validation data that has smaller samples than training data and the below error is produced:
trInput.shape: (4393, 13405) # Size of training data
valInput.shape: (1883, 13405)# Size of validation data
MCA(benzecri=False, check_input=True, copy=True, engine='sklearn',
n_components=2, n_iter='auto', random_state=0)
File "/Modular_helpers_v3.py", line 88, in Aggregate_RareSNPs
Feat_val = mcaObj.transform(valInput)
File "/mca.py", line 272, in transform
return self.row_coordinates(X)
File "/mca.py", line 260, in row_coordinates
return super().row_coordinates(pd.get_dummies(X))
File "/Code/mca.py", line 197, in row_coordinates
data=X @ sparse.diags(self.col_masses_.to_numpy() ** -0.5) @ self.V_.T,
File "/lib/python3.6/site-packages/scipy/sparse/base.py", line 566, in __rmatmul__
return self.__rmul__(other)
File "/lib/python3.6/site-packages/scipy/sparse/base.py", line 550, in __rmul__
return (self.transpose() * tr).transpose()
File "/lib/python3.6/site-packages/scipy/sparse/base.py", line 516, in __mul__
raise ValueError('dimension mismatch')
ValueError: dimension mismatch
BTW, since I am using skopt package and it cannot work with the latest version of sklearn, I am using sklearn = 0.22.0 and copy the MCA code from prince's source code in a file called mca.py and made it working.
The text was updated successfully, but these errors were encountered:
I found the reason of causing this issue and hope that you guys resolve this issue in your package.
The thing is that the number of different categories in my training data is different from my validation data. For example, column one in training data includes values of ['a', 'b','c','a','b','b','c'] and column one in validation data includes values of ['b', 'a', 'a']. So the first column in training data creates 3 dummy variables (for a, b and c) using get_dummy() function while the first column in validation data creates only 2 dummy variables (for a and b). This difference makes the number of dummy columns different in training and validation data and ValueError: dimension mismatch occurs.
Hi,
I am using MCA and apply it on training data and then after fitting the model on training data I would like to apply the model on my validation data that has smaller samples than training data and the below error is produced:
BTW, since I am using
skopt
package and it cannot work with the latest version ofsklearn
, I am usingsklearn = 0.22.0
and copy the MCA code from prince's source code in a file calledmca.py
and made it working.The text was updated successfully, but these errors were encountered: