ShotgunEnsembleClassifier extends ASimplifiedTSClassifier<Integer> { protected List<Integer> mostFrequentLabelsFromWindowLengthPredicitions(final Map<Integer, List<Integer>> windowLengthPredicitions) { int numberOfInstances = windowLengthPredicitions.values().iterator().next().size(); List<Integer> predicitions = new ArrayList<>(numberOfInstances); for (int i = 0; i < numberOfInstances; i++) { Map<Integer, Integer> windowLabelsForInstance = new HashMap<>(); for (Entry<Integer, List<Integer>> entry : windowLengthPredicitions.entrySet()) { int windowLength = entry.getKey(); int predictionForWindowLength = entry.getValue().get(i); windowLabelsForInstance.put(windowLength, predictionForWindowLength); } int mostFrequentLabelForInstance = this.mostFrequentLabelFromWindowLengthPredicitions(windowLabelsForInstance); predicitions.add(mostFrequentLabelForInstance); } return predicitions; } ShotgunEnsembleClassifier(final int minWindowLength, final int maxWindowLength, final boolean meanNormalization, final double factor); @Override Integer predict(final double[] univInstance); @Override List<Integer> predict(final TimeSeriesDataset2 dataset); @Override ShotgunEnsembleLearnerAlgorithm getLearningAlgorithm(final TimeSeriesDataset2 dataset);  }
@Test public void testCorrectnessForMostFrequentLabelsFromWindowLengthPredicitions() { Map<Integer, List<Integer>> windowLengthPredicitions = new HashMap<>(); List<Integer> list1 = Arrays.asList(1, 2, 3, 1, 1); List<Integer> list2 = Arrays.asList(3, 2, 3, 1, 1); List<Integer> list3 = Arrays.asList(2, 1, 3, 2, 1); List<Integer> list4 = Arrays.asList(1, 2, 3, 3, 1); windowLengthPredicitions.put(1, list1); windowLengthPredicitions.put(2, list2); windowLengthPredicitions.put(3, list3); windowLengthPredicitions.put(4, list4); int[] expectation = { 1, 2, 3, 1, 1 }; List<Integer> mostFrequentLabels = this.shotgunEnsembleClassifier.mostFrequentLabelsFromWindowLengthPredicitions(windowLengthPredicitions); assertArrayEquals(expectation, mostFrequentLabels.stream().mapToInt(i -> i).toArray()); }