元の両方のデータを含む新しい ARFF ファイルを作成してみませんか? シンプルな
cat 1.arff > tmp.arff
tail -n+20 2.arff >> tmp.arff
where20
は、arff ヘッダーの行数に置き換えられます。これにより、必要なすべてのインスタンスを含む新しい arff ファイルが生成され、既存のコードでこの新しいファイルを読み取ることができます。
Instances iNew = new ConverterUtils.DataSource(name).getDataSet();
次のドキュメントを使用して、コマンド ラインで weka を呼び出すこともできます: http://old.nabble.com/how-to-merge-two-data-file-a.arff-and-b.arff-into-one-data -リスト--td22890856.html
java weka.core.Instances append filename1 filename2 > output-file
ただし、ドキュメントhttp://weka.sourceforge.net/doc.dev/weka/core/Instances.html#main%28java.lang.Stringには、複数のarffファイルをネイティブに追加できる機能はありませんジャバコード。Weka 3.7.6 の時点で、2 つの arff ファイルを追加するコードは次のとおりです。
// read two files, append them and print result to stdout
else if ((args.length == 3) && (args[0].toLowerCase().equals("append"))) {
DataSource source1 = new DataSource(args[1]);
DataSource source2 = new DataSource(args[2]);
String msg = source1.getStructure().equalHeadersMsg(source2.getStructure());
if (msg != null)
throw new Exception("The two datasets have different headers:\n" + msg);
Instances structure = source1.getStructure();
System.out.println(source1.getStructure());
while (source1.hasMoreElements(structure))
System.out.println(source1.nextElement(structure));
structure = source2.getStructure();
while (source2.hasMoreElements(structure))
System.out.println(source2.nextElement(structure));
}
したがって、Weka 自体は、コードが使用するのと同じプロセスで、データ セット内のすべてのインスタンスを単純に反復処理して出力するように見えます。