我正在尝试从https://cometa.ujaen.es/(例如https://cometa.ujaen.es/datasets/yahoo_arts)下载arff数据集,并使用scipy.arff.loadarff
在python中加载它。你知道吗
然而,scipy似乎希望在头文件后面有一种csv文件,却无法解析绝大多数数据集。你知道吗
例如,复制问题:
from scipy.arff import loadarff
import urllib
urllib.request.urlretrieve('https://cometa.ujaen.es/public/full/yahoo_arts.arff', 'yahoo_arts.arff')
ds = loadarff('yahoo_arts.arff')
(在这个例子中我得到了ValueError: could not convert string to float: '{8 1'
)。你知道吗
这是预期的吗?(aka scipy实现不完全符合arff格式)您知道一些解决方法或一些手工的解析函数吗?你知道吗
谢谢你对这个话题的任何帮助/建议。你知道吗
是的,很不幸。如docstring for ^{} 中所述,“它无法读取具有稀疏数据的文件({}在文件中)。”文件
yahoo_arts.arff
在其@data
部分使用稀疏格式。你知道吗你可以试着searching PyPi for "arff"找到另一种选择。我没有用过这些,所以我没有任何具体的建议。你知道吗
如Warren Weckesser的回答所示,scipy无法读取稀疏arff文件。我已经实现了一个快速的解决方法来解析稀疏的arff文件,如果它能帮助其他人,我将在下面与大家分享。 如果我有时间做一个干净的版本,我会努力为scipy版本做贡献。你知道吗
编辑:对不起,我没有看到你的版本,但我想它也可以。你知道吗
您可以使用以下解决方法:
输出:
相关问题 更多 >
编程相关推荐