Loading the data

In the first step, we'll need to load the data from text files to a Java object. The files are stored in a folder, and each file contains one time series, with values per line. We'll load them into a Double list, as follows:

String filePath = "chap07/ydata/A1Benchmark/real"; 
List<List<Double>> rawData = new ArrayList<List<Double>>(); 

We will need the min and max value for histogram normalization; so, let's collect them in this data pass:

double max = Double.MIN_VALUE; 
double min = Double.MAX_VALUE; 
 
for(int i = 1; i<= 67; i++){ 
  List<Double> sample = new ArrayList<Double>(); 
  BufferedReader reader = new BufferedReader(new  FileReader(filePath+i+".csv")); boolean isAnomaly = false; reader.readLine(); while(reader.ready()){ String ...

Get Machine Learning in Java - Second Edition 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.