Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precision percentage calculation #301

Open
haejunejung opened this issue May 4, 2023 · 2 comments
Open

Precision percentage calculation #301

haejunejung opened this issue May 4, 2023 · 2 comments

Comments

@haejunejung
Copy link

I wonder the calculate precision method, the function calculatePrecisionPercentages divide three parts.
But distance alwasy larger than 0 I think...
This function is included in www/js/precision_calculation.js

current code :

/*
 * Calculate percentage accuracy for each prediction based on distance of
 * the prediction point from the centre point (uses the window height as
 * lower threshold 0%)
 */
function calculatePrecisionPercentages(precisionPercentages, windowHeight, x50, y50, staringPointX, staringPointY) {
  for (x = 0; x < 50; x++) {
    // Calculate distance between each prediction and staring point
    var xDiff = staringPointX - x50[x];
    var yDiff = staringPointY - y50[x];
    var distance = Math.sqrt((xDiff * xDiff) + (yDiff * yDiff));

    // Calculate precision percentage
    var halfWindowHeight = windowHeight / 2;
    var precision = 0;
    if (distance <= halfWindowHeight && distance > -1) {
      precision = 100 - (distance / halfWindowHeight * 100);
    } else if (distance > halfWindowHeight) {
      precision = 0;
    } else if (distance > -1) {
      precision = 100;
    }

    // Store the precision
    precisionPercentages[x] = precision;
  }
}

so, I think below code is more correct. is it right ?

/*
 * Calculate percentage accuracy for each prediction based on distance of
 * the prediction point from the centre point (uses the window height as
 * lower threshold 0%)
 */
function calculatePrecisionPercentages(precisionPercentages, windowHeight, x50, y50, staringPointX, staringPointY) {
  for (x = 0; x < 50; x++) {
    // Calculate distance between each prediction and staring point
    var xDiff = staringPointX - x50[x];
    var yDiff = staringPointY - y50[x];
    var distance = Math.sqrt((xDiff * xDiff) + (yDiff * yDiff));

    // Calculate precision percentage
    var halfWindowHeight = windowHeight / 2;
    var precision = 0;
    if (distance <= halfWindowHeight) {
      precision = 100 - (distance / halfWindowHeight * 100);
    } else {
      precision = 0;
    } 

    // Store the precision
    precisionPercentages[x] = precision;
  }
}
@jeffhuang
Copy link
Contributor

Thanks for reporting @haejunejung . I'll take a look shortly

@jeffhuang
Copy link
Contributor

Yes @haejunejung you are right, it's a slightly simpler but identical bit of code. If you submit a PR and do a quick test to ensure that the result is identical, then I'll merge it. Thanks for finding this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants