问题描述
我想以编程方式创建一个数据集,并提供一些变量。具体来说,在下面的示例中,我有一个实数属性和两个分类属性。有人可以帮我替换我的注释,并在其中添加将变量添加为数据集实例的代码行吗?
// now I do standard setup procedure.
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(new Attribute("age ")); // @ATTRIBUTE age REAL
attributes.add(new Attribute("gender ")); // @attribute gender {F,M}
attributes.add(new Attribute("class ")); // @ATTRIBUTE class {True,False}
Instances dataset = new Instances("TestInstances",attributes,1000);
dataset.setClassIndex(dataset.numAttributes() - 1);
//now I want to add instances of my variables
int age1=1;
String gender1= "F";
String class1= "True";
//what shall I write here to add age1,gender1 and class1 to dataset
int age2=10;
String gender2= "M";
String class2= "True";
// what shall I write here to add age2,gender2 and class2 to dataset
int age3=20;
String gender3= "F";
String class3= "False";
// what shall I write here to add age3,gender3 and class3 to dataset
// now I know how to use dataset … e.g.,RandomForest tree = new RandomForest(); tree.buildClassifier(dataset); etc. etc.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)