elapid icon indicating copy to clipboard operation
elapid copied to clipboard

Boyce index code

Open PC-FSU opened this issue 1 year ago • 5 comments

PR Description: Add Continuous Boyce Index Calculation and Test Cases

Summary:

In this pull request, I have added functionality to calculate the continuous Boyce index as described in Hirzel et al. (2006) . This method provides a reliable way to evaluate habitat suitability models, specifically for presence-only data. Along with the implementation, I have also added test cases to ensure the correctness and robustness of the new function.

Key Updates:

  1. Boyce Index Calculation:

    • Implemented a function to compute the continuous Boyce index based on intervals of habitat suitability values.
    • This includes handling both sliding window and fixed-bin approaches, as well as ensuring compatibility with NumPy, Pandas, and GeoPandas data structures.
    • Added logic to handle edge cases like empty arrays, NaN values, and invalid inputs (e.g., non-1D arrays).
  2. Test Cases:

    • Created test cases to validate the behavior of the Boyce index calculation under various scenarios (e.g., different bin sizes, presence of NaN values).
    • Ensured that the function calculates the correct predicted-to-expected (P/E) ratio and returns accurate Spearman correlation coefficients.
  3. Notebook Update:

    • Updated the notebook WorkingWithGeospatialData.ipynb to include a detailed example demonstrating how to use the continuous Boyce index function.

Testing:

The test cases ensure that the continuous Boyce index function works as expected. The test cases cover:

  • Different binning strategies.
  • Varying habitat suitability ranges.
  • Handling of NaN values in input data.

This PR enhances the project by providing a robust and well-tested method to evaluate habitat suitability models using presence-only data, with clear examples in the updated notebook.

PC-FSU avatar Oct 03 '24 00:10 PC-FSU

Any updates?

PC-FSU avatar Oct 18 '24 15:10 PC-FSU

@PC-FSU let me know if you plan to finish up this contribution. If not, I'll go ahead and merge it and make the remaining updates. Cheers,

earth-chris avatar Mar 22 '25 04:03 earth-chris

@earth-chris Please give me some time. I will be able to push it after 2nd April.

PC-FSU avatar Mar 22 '25 15:03 PC-FSU

I've added the suggestions you mentioned. I also spent some time thinking about how to improve the explanation of the Boyce Index in the notebook, but I couldn't come up with a concise way to do it. Could you clarify what you had in mind? The example in the notebook feels fairly limited.

PC-FSU avatar May 10 '25 22:05 PC-FSU

I've reviewed this PR again and want to document the next steps.

PF-FSU has contributed a large PR with several pieces. There are still a number of changes I want to make to simplify these new features, however. I think this will best be done by merging this PR then submitting the new changes. These include:

  • update the CBI call to accept yobs, ypred as the inputs instead of having users pre-index the background/presence points
  • update the plotting function to compute the CBI values then make the plot, which currently requires x/y values that are the outputs from the CBI function (the mean intervals and f scores, respectively).
  • remove some redundant and verbose type checking and instead simply use .asarray() to enforce type harmonization
  • remove the use of a string 'default' option and instead set a numerical default
  • only import the cbi and plotting functions to the main API
  • add the evaluate.py module to the docs
  • add clearer usage examples in the simple maxent model notebook (instead of the overloaded geospatial data notebook)

earth-chris avatar Sep 17 '25 05:09 earth-chris