如果元素只是名义值或字符串值,我们可以使用 Instance 对象来表示该特定实例。同样对于 Instances 数据集,我们可以通过预定义属性来获取属性。但我有疑问。如果我们想使用集合作为属性元素的值,有什么方法?
例如:
weka.core.Attribute attribute1 = new weka.core.Attribute("list1");
weka.core.Attribute attribute2 = new weka.core.Attribute("list2");
weka.core.Attribute classAttribute = new weka.core.Attribute("Function");
FastVector fvWekaAttributes = new FastVector(3);
fvWekaAttributes.addElement(attribute1);
fvWekaAttributes.addElement(attribute2);
fvWekaAttributes.addElement(classAttribute);
如果两个是标称值,一个是字符串(类),是我们创建属性的方式。以及我们将元素添加到任何数据集(例如:trainInstances)的方式,我们创建实例对象并添加如下:
Instance iExample = new Instance(3);
iExample.setValue((weka.core.Attribute)fvWekaAttributes.elementAt(0), 10);
iExample.setValue((weka.core.Attribute)fvWekaAttributes.elementAt(0), 15);
iExample.setValue((weka.core.Attribute)fvWekaAttributes.elementAt(2), "F1");
trainInstances.add(iExample);
这没关系,但是我应该用什么来存储列表/集合而不是单个标称值。我想这样做:
int[] list1={10,20,30,40};
int[] list2={90,80,70,60};
iExample.setValue((weka.core.Attribute)fvWekaAttributes.elementAt(0), **list1**);
iExample.setValue((weka.core.Attribute)fvWekaAttributes.elementAt(0), **list2**);
iExample.setValue((weka.core.Attribute)fvWekaAttributes.elementAt(2), "F1");
trainInstances.add(iExample);
更具体地说,这些列表有时可能会改变它们的大小。即,在这个例子中,我们看到每个长度为 4 的列表,但应该支持其他实例对象中不同大小的列表。是否可以使用 WEKA 或任何学习 API。如果有,请提供资源。这是我硕士论文的必修课。。