简体   繁体   English

如何使用python和pandas将Csv文件转换为libsvm?

[英]how to convert Csv file to libsvm using python and pandas?

I had one csv file and i needed to convert it to libsvm format so i wrote a python script to make the required changes . 我有一个csv文件,我需要将其转换为libsvm格式,因此我编写了python脚本来进行所需的更改。 Now the matrix i have in python is in the libsvm form but how to write it to libsvm format . 现在我在python中拥有的矩阵为libsvm形式,但是如何将其写入libsvm格式。 But now how to save it in file.libsvm ? 但是现在如何将其保存在file.libsvm中?

pandas module has data.to_csv snd csv module has csv writer . pandas模块具有data.to_csv snd csv模块具有csv writer。 is there any way i can save it in libsvm format . 有什么办法可以将它保存为libsvm格式。 I am thinking of saving it as txt file then i'll rename it . 我正在考虑将其另存为txt文件,然后将其重命名。 Don't know will it work it or not . 不知道它是否有用。 I read the data using data=pd.read_csv('abc.csv',header=None,index_col=False) and made the required changes . 我使用data = pd.read_csv('abc.csv',header = None,index_col = False)读取数据并进行了所需的更改。 so now data has the file to be saved . 因此,现在数据已保存了文件。

Look into phraug , it has been made for this purpose. 查看phraug ,它是为此目的而制成的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM