0
$\begingroup$

I have a (.csv) file with more than 35,000 rows and 100 columns, where the rows represent the attributes and columns represent the instances. In Excel the maximum number of columns is 16,384. Therefore, it is impossible to do this in one single Excel sheet. I need my dataset to be transposed in order to perform some machine learning algorithms in WEKA. Is there any tool allow such thing like this?

Also, is there a way to transpose (.arff) file in WEKA?

$\endgroup$
0
$\begingroup$

This is possible to do in WEKA, but it only works if:

  • the first column of your data is of string or nominal type, and
  • the rest of your columns are numeric.

Open the dataset in the explorer, and first remove the class attribute by choosing 'No Class' from the drop-down menu on the right. Then, apply the filter from filters.unsupervised.attribute.Transpose. After this, you should re-apply the class attribute by re-selecting the class attribute in the drop-down menu.

If your data doesn't meet the requirements listed above, I would recommend using this short python script to do it:

import pandas as pd
df = pd.read_csv('your_file_here.csv', index=False)
df.transpose().to_csv('your_new_file_here.csv', index=False)

and then loading the new file into WEKA.

| improve this answer | |
$\endgroup$
  • $\begingroup$ that works!!! Could you please tell if there is a way to view the complete table because in WEKA's viewer it's limited. In fact, it's not showing the last columns, just showing (...) due to the high-dimensional dataset I have. $\endgroup$ – Abdulaziz Ghalib Apr 14 '18 at 19:42
  • $\begingroup$ After applying the Transpose filter, the first attribute of my dataset becomes (String) whereas it should be (Numeric). $\endgroup$ – Abdulaziz Ghalib Apr 18 '18 at 20:25
  • $\begingroup$ edited comment of the above... Another issue after applying the Transpose filter...... My original dataset used to have the first column as Nominal and the rest is Numeric. After applying the Transpose filter, the first columns becomes now the first row, this is good! but the problem now is WEKA considering the transposed dataset first column as String where it should be Numeric because it contains Numeric values. Any suggestions to fix this would be greatly appreciated. $\endgroup$ – Abdulaziz Ghalib Apr 18 '18 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.