I have a few arff files. I would like to read them sequentially and create a large dataset. Instances.add(Instance inst) doesn’t add string values to the instances, hence the attempt to setDataset() … but even this fails. Is there a way to accomplish the intuitively correct thing for strings?
ArffLoader arffLoader = new ArffLoader();
arffLoader.setFile(new File(fName));
Instances newData = arffLoader.getDataSet();
for (int i = 0; i < newData.numInstances(); i++) {
Instance one = newData.instance(i);
one.setDataset(data);
data.add(one);
}
This is from mailing list. I saved it before
Depends what merge you are talking about. Do you just want to append
the second file (both have the same attributes) or do you want to add
the merge the attributes (both have the same number of instances)?
Here’s the relevant Javadoc:
http://weka.sourceforge.net/doc.dev/weka/core/Instances.html#main(java.lang.String%5B%5D)
Use mergeInstances to merge two datasets.
Your code would be something like below. For same instance numbers.
Your code would be something like below. For same attribute numbers. I do not see any java method in weka. If you read code there is something like below.