@Test public void test() throws Exception { DataStreamsExample.main(null); }
public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataSetGenerator.generate(1,10,5,5); System.out.println("Attributes defining the data set"); for (Attribute attribute : data.getAttributes()) { System.out.println(attribute.getName()); } Attribute discreteVar0 = data.getAttributes().getAttributeByName("DiscreteVar0"); System.out.println("1. Iterating over samples using a for loop"); for (DataInstance dataInstance : data) { System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } System.out.println("2. Iterating using streams."); data.restart(); data.stream().forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("3. Iterating using parallel streams."); data.restart(); data.parallelStream(10).forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("4. Iterating over a stream of data batches."); data.restart(); data.streamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("5. Iterating over a parallel stream of data batches."); data.restart(); data.parallelStreamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("6. Iterating over data batches using a for loop."); for (DataOnMemory<DataInstance> batch : data.iterableOverBatches(10)) { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } }
DataStreamsExample { public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataSetGenerator.generate(1,10,5,5); System.out.println("Attributes defining the data set"); for (Attribute attribute : data.getAttributes()) { System.out.println(attribute.getName()); } Attribute discreteVar0 = data.getAttributes().getAttributeByName("DiscreteVar0"); System.out.println("1. Iterating over samples using a for loop"); for (DataInstance dataInstance : data) { System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } System.out.println("2. Iterating using streams."); data.restart(); data.stream().forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("3. Iterating using parallel streams."); data.restart(); data.parallelStream(10).forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("4. Iterating over a stream of data batches."); data.restart(); data.streamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("5. Iterating over a parallel stream of data batches."); data.restart(); data.parallelStreamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("6. Iterating over data batches using a for loop."); for (DataOnMemory<DataInstance> batch : data.iterableOverBatches(10)) { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } } }
DataStreamsExample { public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataSetGenerator.generate(1,10,5,5); System.out.println("Attributes defining the data set"); for (Attribute attribute : data.getAttributes()) { System.out.println(attribute.getName()); } Attribute discreteVar0 = data.getAttributes().getAttributeByName("DiscreteVar0"); System.out.println("1. Iterating over samples using a for loop"); for (DataInstance dataInstance : data) { System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } System.out.println("2. Iterating using streams."); data.restart(); data.stream().forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("3. Iterating using parallel streams."); data.restart(); data.parallelStream(10).forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("4. Iterating over a stream of data batches."); data.restart(); data.streamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("5. Iterating over a parallel stream of data batches."); data.restart(); data.parallelStreamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("6. Iterating over data batches using a for loop."); for (DataOnMemory<DataInstance> batch : data.iterableOverBatches(10)) { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } }  }
DataStreamsExample { public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataSetGenerator.generate(1,10,5,5); System.out.println("Attributes defining the data set"); for (Attribute attribute : data.getAttributes()) { System.out.println(attribute.getName()); } Attribute discreteVar0 = data.getAttributes().getAttributeByName("DiscreteVar0"); System.out.println("1. Iterating over samples using a for loop"); for (DataInstance dataInstance : data) { System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } System.out.println("2. Iterating using streams."); data.restart(); data.stream().forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("3. Iterating using parallel streams."); data.restart(); data.parallelStream(10).forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("4. Iterating over a stream of data batches."); data.restart(); data.streamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("5. Iterating over a parallel stream of data batches."); data.restart(); data.parallelStreamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("6. Iterating over data batches using a for loop."); for (DataOnMemory<DataInstance> batch : data.iterableOverBatches(10)) { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } }  static void main(String[] args); }
DataStreamsExample { public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataSetGenerator.generate(1,10,5,5); System.out.println("Attributes defining the data set"); for (Attribute attribute : data.getAttributes()) { System.out.println(attribute.getName()); } Attribute discreteVar0 = data.getAttributes().getAttributeByName("DiscreteVar0"); System.out.println("1. Iterating over samples using a for loop"); for (DataInstance dataInstance : data) { System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } System.out.println("2. Iterating using streams."); data.restart(); data.stream().forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("3. Iterating using parallel streams."); data.restart(); data.parallelStream(10).forEach(dataInstance -> System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)) ); System.out.println("4. Iterating over a stream of data batches."); data.restart(); data.streamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("5. Iterating over a parallel stream of data batches."); data.restart(); data.parallelStreamOfBatches(10).forEach(batch -> { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); }); System.out.println("6. Iterating over data batches using a for loop."); for (DataOnMemory<DataInstance> batch : data.iterableOverBatches(10)) { for (DataInstance dataInstance : batch) System.out.println("The value of attribute A for the current data instance is: " + dataInstance.getValue(discreteVar0)); } }  static void main(String[] args);  }