Java 如何获取日期属性的值数
我想使用Date属性的值的数量来迭代某些内容。然而,当我使用属性的numValues函数时,我得到了0,尽管有144个实例具有唯一的日期 我正在使用airline.arff,这是weka应用程序中包含的一个演示arff文件Java 如何获取日期属性的值数,java,weka,Java,Weka,我想使用Date属性的值的数量来迭代某些内容。然而,当我使用属性的numValues函数时,我得到了0,尽管有144个实例具有唯一的日期 我正在使用airline.arff,这是weka应用程序中包含的一个演示arff文件 int numberOfValues = this.data.classAttribute().numValues() for (int classLabelIndex = 0; classLabelIndex < numberOfValues; classLabelI
int numberOfValues = this.data.classAttribute().numValues()
for (int classLabelIndex = 0; classLabelIndex < numberOfValues; classLabelIndex++) {
String classLabel = this.data.classAttribute().value(classLabelIndex);
AttributeMap attributes = setAttributes();
this.groups.put(classLabel, attributes);
}
int numberOfValues=this.data.classAttribute().numValues()
对于(int-classLabelIndex=0;classLabelIndex
我知道,使用此数据集,我可以只使用实例数,但我也希望能够将其用于其他arff文件,其中可能有更多具有相同日期的实例。日期属性被视为数字属性
numValues
对于非标称属性将返回0。相反,您需要遍历数据行本身并收集值,例如,在哈希集中:
导入weka.core.Instances;
导入weka.core.ConverterUtils.DataSource;
导入java.util.HashSet;
公共类iterateValues{
公共静态void main(字符串[]args)引发异常{
实例数据=DataSource.read(args[0]);
int index=Integer.parseInt(args[1]);
HashSet值=新的HashSet();
对于(int i=0;i