@Test public void testThatOutliersFromARealMapAreDetected() throws NicTrackerException { final Set<NicGeoPoint> geoPointsIn = CandidateFixtures.createCandidatesOutliersFromARealMap(); final Set<NicGeoPoint> expected = CandidateFixtures.createCandidatesOutliersFromARealMapExpected(); final Set<NicGeoPoint> geoPointsOut = cme.removeOutliers(geoPointsIn); assertEquals(expected, geoPointsOut); }
@Override public Set<T> removeOutliers(Set<T> candidates) { final PointList<T> candidateList = new PointList<T>(pointFactory, candidates); if (candidateList.size() <= 2) { return candidates; } final T centroid = candidateList.getMedianPoint(); final double medianCentroidDistance = candidateList.calculateMedianReferencePointDistance(centroid); final double thresholdDistance = medianThresholdFactor * medianCentroidDistance; final Iterator<T> it = candidates.iterator(); while (it.hasNext()) { final NicGeoPoint point = it.next(); if (point.calculateDistanceTo(centroid) > thresholdDistance) { it.remove(); } } return candidates; }
CentroidMedianEliminator implements OutlierEliminator<T> { @Override public Set<T> removeOutliers(Set<T> candidates) { final PointList<T> candidateList = new PointList<T>(pointFactory, candidates); if (candidateList.size() <= 2) { return candidates; } final T centroid = candidateList.getMedianPoint(); final double medianCentroidDistance = candidateList.calculateMedianReferencePointDistance(centroid); final double thresholdDistance = medianThresholdFactor * medianCentroidDistance; final Iterator<T> it = candidates.iterator(); while (it.hasNext()) { final NicGeoPoint point = it.next(); if (point.calculateDistanceTo(centroid) > thresholdDistance) { it.remove(); } } return candidates; } }
CentroidMedianEliminator implements OutlierEliminator<T> { @Override public Set<T> removeOutliers(Set<T> candidates) { final PointList<T> candidateList = new PointList<T>(pointFactory, candidates); if (candidateList.size() <= 2) { return candidates; } final T centroid = candidateList.getMedianPoint(); final double medianCentroidDistance = candidateList.calculateMedianReferencePointDistance(centroid); final double thresholdDistance = medianThresholdFactor * medianCentroidDistance; final Iterator<T> it = candidates.iterator(); while (it.hasNext()) { final NicGeoPoint point = it.next(); if (point.calculateDistanceTo(centroid) > thresholdDistance) { it.remove(); } } return candidates; } CentroidMedianEliminator(PointFactory factory, final double medianThresholdFactor); }
CentroidMedianEliminator implements OutlierEliminator<T> { @Override public Set<T> removeOutliers(Set<T> candidates) { final PointList<T> candidateList = new PointList<T>(pointFactory, candidates); if (candidateList.size() <= 2) { return candidates; } final T centroid = candidateList.getMedianPoint(); final double medianCentroidDistance = candidateList.calculateMedianReferencePointDistance(centroid); final double thresholdDistance = medianThresholdFactor * medianCentroidDistance; final Iterator<T> it = candidates.iterator(); while (it.hasNext()) { final NicGeoPoint point = it.next(); if (point.calculateDistanceTo(centroid) > thresholdDistance) { it.remove(); } } return candidates; } CentroidMedianEliminator(PointFactory factory, final double medianThresholdFactor); @Override Set<T> removeOutliers(Set<T> candidates); }
CentroidMedianEliminator implements OutlierEliminator<T> { @Override public Set<T> removeOutliers(Set<T> candidates) { final PointList<T> candidateList = new PointList<T>(pointFactory, candidates); if (candidateList.size() <= 2) { return candidates; } final T centroid = candidateList.getMedianPoint(); final double medianCentroidDistance = candidateList.calculateMedianReferencePointDistance(centroid); final double thresholdDistance = medianThresholdFactor * medianCentroidDistance; final Iterator<T> it = candidates.iterator(); while (it.hasNext()) { final NicGeoPoint point = it.next(); if (point.calculateDistanceTo(centroid) > thresholdDistance) { it.remove(); } } return candidates; } CentroidMedianEliminator(PointFactory factory, final double medianThresholdFactor); @Override Set<T> removeOutliers(Set<T> candidates);  }