Add an option to the epc function to also get the thresholds which were used during calculation

parent 142014da
Pipeline #8405 passed with stages
in 12 minutes and 28 seconds
 ... @@ -514,14 +514,16 @@ blitz::Array bob::measure::epc ... @@ -514,14 +514,16 @@ blitz::Array bob::measure::epc (const blitz::Array& dev_negatives, (const blitz::Array& dev_negatives, const blitz::Array& dev_positives, const blitz::Array& dev_positives, const blitz::Array& test_negatives, const blitz::Array& test_negatives, const blitz::Array& test_positives, size_t points, bool isSorted) { const blitz::Array& test_positives, size_t points, bool isSorted, bool thresholds) { blitz::Array dev_neg, dev_pos; blitz::Array dev_neg, dev_pos; sort(dev_negatives, dev_neg, isSorted); sort(dev_negatives, dev_neg, isSorted); sort(dev_positives, dev_pos, isSorted); sort(dev_positives, dev_pos, isSorted); double step = 1.0/((double)points-1.0); double step = 1.0/((double)points-1.0); blitz::Array retval(2, points); auto retval_shape0 = (thresholds) ? 3 : 2; blitz::Array retval(retval_shape0, points); for (int i=0; i<(int)points; ++i) { for (int i=0; i<(int)points; ++i) { double alpha = (double)i*step; double alpha = (double)i*step; retval(0,i) = alpha; retval(0,i) = alpha; ... @@ -530,6 +532,9 @@ blitz::Array bob::measure::epc ... @@ -530,6 +532,9 @@ blitz::Array bob::measure::epc std::pair ratios = std::pair ratios = bob::measure::farfrr(test_negatives, test_positives, threshold); bob::measure::farfrr(test_negatives, test_positives, threshold); retval(1,i) = (ratios.first + ratios.second) / 2; retval(1,i) = (ratios.first + ratios.second) / 2; if (thresholds) { retval(2,i) = threshold; } } } return retval; return retval; } }
 ... @@ -365,12 +365,14 @@ namespace bob { namespace measure { ... @@ -365,12 +365,14 @@ namespace bob { namespace measure { /** /** * Calculates the EPC curve given a set of positive and negative scores and a * Calculates the EPC curve given a set of positive and negative scores and a * number of desired points. Returns a two-dimensional blitz::Array of * number of desired points. Returns a two-dimensional blitz::Array of * doubles that express the X (cost) and Y (HTER on the test set given the * doubles that express the X (cost), Y (HTER on the test set given the min. * min. HTER threshold on the development set) coordinates in this order. * HTER threshold on the development set) coordinates, and the thresholds * Please note that, in order to calculate the EPC curve, one needs two sets * which were used during calculations (dependig on the `thresholds` * of data comprising a development set and a test set. The minimum weighted * argument) in this order. Please note that, in order to calculate the EPC * error is calculated on the development set and then applied to the test * curve, one needs two sets of data comprising a development set and a test * set to evaluate the half-total error rate at that position. * set. The minimum weighted error is calculated on the development set and * then applied to the test set to evaluate the half-total error rate at that * position. * * * The EPC curve plots the HTER on the test set for various values of 'cost'. * The EPC curve plots the HTER on the test set for various values of 'cost'. * For each value of 'cost', a threshold is found that provides the minimum * For each value of 'cost', a threshold is found that provides the minimum ... @@ -387,7 +389,8 @@ namespace bob { namespace measure { ... @@ -387,7 +389,8 @@ namespace bob { namespace measure { const blitz::Array& test_negatives, const blitz::Array& test_negatives, const blitz::Array& test_positives, const blitz::Array& test_positives, size_t points, size_t points, bool isSorted = false); bool isSorted = false, bool thresholds = false); }} }} ... ...