/** * Calculates the distance between two instances. Offers speed up (if the * distance function class in use supports it) in nearest neighbour search by * taking into account the cutOff or maximum distance. Depending on the * distance function class, post processing of the distances by * postProcessDistances(double []) may be required if this function is used. * * @param first the first instance * @param second the second instance * @param cutOffValue If the distance being calculated becomes larger than * cutOffValue then the rest of the calculation is discarded. * @param stats the performance stats object * @return the distance between the two given instances or * Double.POSITIVE_INFINITY if the distance being calculated becomes * larger than cutOffValue. */ public double distance(Instance first, Instance second, double cutOffValue, PerformanceStats stats) { try { m_Remove.input(first); m_Filter.input(m_Remove.output()); Instance firstFiltered = m_Filter.output(); m_Remove.input(second); m_Filter.input(m_Remove.output()); Instance secondFiltered = m_Filter.output(); return m_Distance.distance(firstFiltered, secondFiltered, cutOffValue, stats); } catch (Exception e) { e.printStackTrace(); return -1; } }
/** * Calculates the distance (or similarity) between two instances. Need to pass * this returned distance later on to postprocess method to set it on correct * scale. <br/> * P.S.: Please don't mix the use of this function with distance(Instance * first, Instance second), as that already does post processing. Please * consider passing Double.POSITIVE_INFINITY as the cutOffValue to this * function and then later on do the post processing on all the distances. * * @param first the first instance * @param second the second instance * @param stats the structure for storing performance statistics. * @return the distance between the two given instances or * Double.POSITIVE_INFINITY. */ @Override public double distance(Instance first, Instance second, PerformanceStats stats) { // debug // method // pls // remove // after // use return Math.pow(distance(first, second, Double.POSITIVE_INFINITY, stats), 1 / m_Order); }
/** * Calculates the distance between two instances. * * @param first the first instance * @param second the second instance * @param stats the performance stats object * @return the distance between the two given instances * @throws Exception if calculation fails */ public double distance(Instance first, Instance second, PerformanceStats stats) throws Exception { return distance(first, second, Double.POSITIVE_INFINITY, stats); }
/** * Calculates the distance (or similarity) between two instances. Need to * pass this returned distance later on to postprocess method to set it on * correct scale. <br/> * P.S.: Please don't mix the use of this function with * distance(Instance first, Instance second), as that already does post * processing. Please consider passing Double.POSITIVE_INFINITY as the cutOffValue to * this function and then later on do the post processing on all the * distances. * * @param first the first instance * @param second the second instance * @param stats the structure for storing performance statistics. * @return the distance between the two given instances or * Double.POSITIVE_INFINITY. */ public double distance(Instance first, Instance second, PerformanceStats stats) { //debug method pls remove after use return Math.sqrt(distance(first, second, Double.POSITIVE_INFINITY, stats)); }
/** * Calculates the distance between two instances. * * @param first the first instance * @param second the second instance * @param stats the performance stats object * @return the distance between the two given instances * @throws Exception if calculation fails */ public double distance(Instance first, Instance second, PerformanceStats stats) throws Exception;
/** * Calculates the distance between two instances. Offers speed up (if the * distance function class in use supports it) in nearest neighbour search by * taking into account the cutOff or maximum distance. Depending on the * distance function class, post processing of the distances by * postProcessDistances(double []) may be required if this function is used. * * @param first the first instance * @param second the second instance * @param cutOffValue If the distance being calculated becomes larger than * cutOffValue then the rest of the calculation is discarded. * @param stats the performance stats object * @return the distance between the two given instances or * Double.POSITIVE_INFINITY if the distance being calculated becomes * larger than cutOffValue. */ public double distance(Instance first, Instance second, double cutOffValue, PerformanceStats stats);
/** * Calculates the distance between two instances. * * @param first the first instance * @param second the second instance * @param stats the performance stats object * @return the distance between the two given instances */ @Override public double distance(Instance first, Instance second, PerformanceStats stats) { return distance(first, second, Double.POSITIVE_INFINITY, stats); }
/** * Calculates the distance between two instances. Offers speed up (if the * distance function class in use supports it) in nearest neighbour search by * taking into account the cutOff or maximum distance. Depending on the * distance function class, post processing of the distances by * postProcessDistances(double []) may be required if this function is used. * * @param first the first instance * @param second the second instance * @param cutOffValue If the distance being calculated becomes larger than * cutOffValue then the rest of the calculation is * discarded. * @param stats the performance stats object * @return the distance between the two given instances or * Double.POSITIVE_INFINITY if the distance being * calculated becomes larger than cutOffValue. */ public double distance(Instance first, Instance second, double cutOffValue, PerformanceStats stats);
/** * Calculates the distance (or similarity) between two instances. Need to * pass this returned distance later on to postprocess method to set it on * correct scale. <br/> * P.S.: Please don't mix the use of this function with * distance(Instance first, Instance second), as that already does post * processing. Please consider passing Double.POSITIVE_INFINITY as the cutOffValue to * this function and then later on do the post processing on all the * distances. * * @param first the first instance * @param second the second instance * @param stats the structure for storing performance statistics. * @return the distance between the two given instances or * Double.POSITIVE_INFINITY. */ public double distance(Instance first, Instance second, PerformanceStats stats) { //debug method pls remove after use return Math.pow(distance(first, second, Double.POSITIVE_INFINITY, stats), 1/m_Order); }
/** * Calculates the distance between two instances. * * @param first the first instance * @param second the second instance * @param stats the performance stats object * @return the distance between the two given instances */ public double distance(Instance first, Instance second, PerformanceStats stats) { return distance(first, second, Double.POSITIVE_INFINITY, stats); }