November 2019
Intermediate to advanced
304 pages
8h 40m
English
// convert URI to string final String data = IOUtils.toString(new URL(url),"utf-8"); // Get sequences from the raw data final String[] sequences = data.split("\n"); final List<Pair<String,Integer>> contentAndLabels = new ArrayList<>(); int lineCount = 0; for(String sequence : sequences) { // Record each time step in new line sequence = sequence.replaceAll(" +","\n"); // Labels: first 100 examples (lines) are label 0, second 100 examples are label 1, and so on contentAndLabels.add(new Pair<>(sequence, lineCount++ / 100)); }
for(Pair<String,Integer> sequencePair : contentAndLabels) ...