We will now look at how to read and write a dataset. Let's get to our Java code. Create a project and name it Datasets. Now, import the weka.jar file, as performed in the previous section. Once we have the weka.jar file available, we can read the core, Instance interfaces, ArffSaver, DataSource, and io.File packages, as shown in the following screenshot:
We will start with DataSource. DataSource is a class that helps us to open a dataset file that is available in Weka. By default, Weka works with ARFF files; see the following code:
DataSource src = new DataSource("/Users/admin/wekafiles/data/weather.numeric.arff");
Instances dt= src.getDataSet();
System.out.println(dt.toSummaryString());
ArffSaver as = new ArffSaver();
As we can see in the preceding code, we created an object for DataSource and provided a path to the ARFF file that...