Cross-validating a machine learning model
In this recipe, we will be creating four methods that will be doing four different things--one method will load an ARFF file (assuming that the ARFF file is already created and saved somewhere); the second method will read the data in the ARFF file and generate a machine-learning model (we have arbitrarily chosen Naive Bayes model); the third method will be saving the model by using serialization, and the last method will be evaluating the model on the ARFF file using a 10-fold cross-validation.
How to do it...
- Create two instance variables. The first will contain all the instances of the iris dataset. The iris ARFF dataset can be found in the data folder of your installed Weka directory. The second variable ...
Get Java Data Science Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.