0
我在使用Java中的WEKA开展数据挖掘项目并且说明中说我必须为数据集中的每个属性创建一个Attribute对象并将它们添加到FastVector。我试图看看API,但我认为我没有做到这一点,有人可以告诉我正确的做法。我使用的iris.arff文件如何在Weka中创建属性
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instances;
import weka.core.converters.ArffSaver;
public class StartWeka {
\t public static void main(String[]args)throws Exception{
\t \t
\t \t Instances dataset = new Instances(new BufferedReader(new FileReader("C:/Users/Student/workspace/Data Mining/src/iris.arff.txt")));
\t \t
\t \t Instances train = new Instances(dataset);
\t \t train.setClassIndex(train.numAttributes()-1);
\t \t
\t \t System.out.println(dataset.toSummaryString());
\t \t
\t \t Attribute a1 = new Attribute("sepallength", 0);
Attribute a2 = new Attribute("sepalwidth", 1);
Attribute a3 = new Attribute("petalwidth", 2);
FastVector attrs = new FastVector();
\t \t attrs.addElement(a1);
\t }
}