我正在学习使用Weka进行聚类问题。使用ARFF文件对我来说是新的。我有一个疑问,经过搜索我没能在线找到解决方案。问题是从ARFF文件中访问特定属性。例如,我的文件内容如下,
@relation whatever@attribute Latitude numeric@attribute Longitude numeric@attribute NoOfEmp numeric@attribute Revenue numeric@attribute Type4 numeric@attribute Type6 numeric@attribute Type7 numeric@attribute Type8 numeric@attribute Type9 numeric@attribute Type10 numeric@attribute Type11 numeric@data0.456,0.029,-0.143,-0.143,1,0,0,0,0,0,00.443,0.032,-0.286,-0.286,1,0,0,0,0,0,00.487,0.012,-0.286,-0.286,1,0,0,0,0,0,00.435,0.027,-0.286,-0.286,1,0,0,0,0,0,00.467,-0.01,-0.143,-0.143,1,0,0,0,0,0,00.484,0.007,-0.286,-0.286,1,0,0,0,0,0,00.456,0.029,-0.286,-0.286,1,0,0,0,0,0,00.457,0.032,0.286,0.286,0,0,1,0,0,0,00.486,-0.019,0.286,0.286,0,0,1,0,0,0,0
使用X-Means聚类算法,上述每一行都被视为一个实例,也就是说,如果我说给出第四个实例,它会给出
0.435,0.027,-0.286,-0.286,1,0,0,0,0,0,0
但我需要的是仅提取一个属性,比如从上述实例中提取”-0.286″。我尝试过instance[2],但它显示“对象不可索引”。我对此完全是新手,有人能帮我解决这个问题吗?
任何帮助都将非常有用。
提前感谢。
回答:
我已经找到了答案。是"data.instance(2).value(3)"