Skip to Content
Machine Learning in Java - Second Edition
book

Machine Learning in Java - Second Edition

by AshishSingh Bhatia, Bostjan Kaluza
November 2018
Intermediate to advanced
300 pages
7h 42m
English
Packt Publishing
Content preview from Machine Learning in Java - Second Edition

Loading data

Before we start the analysis, we will load the data in Weka's Attribute-Relation File Format (ARFF) and print the total number of loaded instances. Each data sample is held within a DataSource object, while the complete dataset, accompanied by meta-information, is handled by the Instances object.

To load the input data, we will use the DataSource object that accepts a variety of file formats and converts them into Instances:

DataSource source = new DataSource("data/zoo.arff"); 
Instances data = source.getDataSet(); System.out.println(data.numInstances() + " instances loaded."); 
System.out.println(data.toString()); 

This will provide the number of loaded instances as output, as follows:

101 instances loaded.

We can also print ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Java Machine Learning

Mastering Java Machine Learning

Uday Kamath, Krishna Choppella
Java: Data Science Made Easy

Java: Data Science Made Easy

Richard M. Reese, Jennifer L. Reese, Alexey Grigorev

Publisher Resources

ISBN: 9781788474399Supplemental Content