gpt4 book ai didi

python - ARFF 文件的布局无效

转载 作者:太空宇宙 更新时间:2023-11-04 03:13:13 28 4
gpt4 key购买 nike

我有一个从 liac-weka 包生成的 ARFF 文件。

 % Finger-tapped_dataset
@RELATION Feature_onsets
@ATTRIBUTE file STRING
@ATTRIBUTE nOnset INTEGER
@ATTRIBUTE Duration REAL
@ATTRIBUTE RMS.mean REAL
@ATTRIBUTE RMS.var REAL
@ATTRIBUTE spectralCentroid.mean REAL
@ATTRIBUTE spectralCentroid.var REAL

@DATA
sound_1,1,0.859138309956,0.00811793841422,0.000330115522956,0.0686389952898,8.52151861181e-05
sound_1,2,0.719818592072,0.0209680441767,0.00351395853795,0.0674178153276,0.000161568881595
sound_1,3,0.661768734455,0.021980991587,0.00362967769615,0.0664032921195,0.000200695401873
sound_1,4,0.441179126501,0.0213470663875,0.0032624185551,0.0699469298124,0.00039628680679
sound_1,5,0.9287981987,0.0224026963115,0.00370181445032,0.0690619647503,0.000339957477991
sound_1,6,0.917188227177,0.0215289667249,0.00351273571141,0.0691223442554,0.000326170702465
sound_1,7,0.441179126501,0.0240413267165,0.00402954593301,0.0688840150833,0.000323307351209
sound_1,8,0.243809521198,0.0253500081599,0.00412592897192,0.0682555362582,0.000328328402247
sound_1,9,0.673378705978,0.0244132820517,0.00386085407808,0.0677450224757,0.000302833941532
sound_1,10,0.487619042397,0.025617858395,0.004043656867,0.06802662462,0.000307480600895
sound_1,11,1.61451244354,0.0236539077014,0.00386097631417,0.0858256071806,0.00764736300334
%
%
%

尝试阅读时:

import arff
arff.loads('result.arff')

我收到以下错误:

arff.BadLayout: Invalid layout of the ARFF file, at line 1

我找不到问题所在。 Weka 打开文件但不使用 python 包...有什么想法吗?提前致谢!

最佳答案

https://pythonhosted.org/liac-arff/ 查看 ARFF 模块文档, load() 将文件对象作为输入。看起来你在 result.arff 文件中有上述数据,所以你应该加载它:

fp = open('result.arff')
testdata = arff.load(fp)

这应该可以解决上述与 arff.BadLayout 相关的错误。

关于python - ARFF 文件的布局无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37280306/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com