Я хочу добавить некоторые атрибуты, которые имеют номинальные значения int. Но я не знаю, как объявить его номинальным и добавить возможные значения.
Я создал ArrayList, преобразовал возможные значения int в строку и добавил его. Но я не думаю, что это нормально.
public class ModelClassifier {
private ArrayList<Attribute> attributes = new ArrayList<Attribute>();
private ArrayList<String> classVal = new ArrayList<String>();
// nominal attribute, classval
private ArrayList<String> methods = new ArrayList<String>();
// nominal attribute
private ArrayList<String> winners = new ArrayList<String>();
// nominal attribute
private Instances dataRaw;
public ModelClassifier() {
for(int i=0; i<32; ++i) classVal.add(i+"");
for(int i=0; i<5; ++i) methods.add(i+"");
for(int i=0; i<6; ++i) winners.add(i+"");
attributes.add(new Attribute("model", classVal));
attributes.add(new Attribute("method", methods));
attributes.add(new Attribute("candidate1_1"));
attributes.add(new Attribute("candidate1_2"));
attributes.add(new Attribute("candidate2_1"));
attributes.add(new Attribute("candidate2_2"));
attributes.add(new Attribute("candidate3_1"));
attributes.add(new Attribute("candidate3_2"));
attributes.add(new Attribute("candidate4_1"));
attributes.add(new Attribute("candidate4_2"));
attributes.add(new Attribute("candidate5_1"));
attributes.add(new Attribute("candidate5_2"));
attributes.add(new Attribute("candidate6_1"));
attributes.add(new Attribute("candidate6_2"));
attributes.add(new Attribute("avg"));
attributes.add(new Attribute("dev"));
attributes.add(new Attribute("winner", winners));
dataRaw = new Instances("TestInstances", attributes, 0);
dataRaw.setClassIndex(0);
}
public Instances createInstance(double[] instanceValue1) {
dataRaw.clear();
dataRaw.add(new DenseInstance(1.0, instanceValue1));
return dataRaw;
}
}
Этот код действительно работал, но я очень подозрительно к нему отношусь. Я думаю, что что-то упустил. Я публикую часть файла arff, который использовал для обучения модели.