In this section, we will look at how to convert a dataset. We will learn how to convert a CSV file to an ARFF file, and vice versa.
Converting datasets
Converting an ARFF file to a CSV file
First, let's look at the code. Suppose that we have a weather.arff file. We will first import the following packages:
import weka.core.Instances;
import weka.core.converters.ArffLoader;
import weka.core.converters.CSVSaver;
import java.io.File;
We have started with the ArffLoader class, and have created an object, loader, for it:
ArffLoader loader = new ArffLoader();
We have then assigned a filename, weather.arff, to the ArffLoader class, as seen in the following code:
loader.setSource(new File("weather.arff")); //Use...