Skip to content

Improve Test Data for Precision-Recall Curve to Show Realistic Shape#124

Merged
idanmoradarthas merged 2 commits into
masterfrom
100-improve-test-data-for-precision-recall-curve-to-show-realistic-shape
Apr 24, 2026
Merged

Improve Test Data for Precision-Recall Curve to Show Realistic Shape#124
idanmoradarthas merged 2 commits into
masterfrom
100-improve-test-data-for-precision-recall-curve-to-show-realistic-shape

Conversation

@idanmoradarthas

Copy link
Copy Markdown
Owner

Resolves

Resolves #100

Description

This pull request addresses the need for realistic Precision-Recall curve test visualizations. The previous mock data generated arbitrary, near-perfect (right-angle) PR curves that did not accurately reflect real-world, descending trade-off curve shapes.

To solve this, a new dataset simulating a challenging classification task (with increased label noise and reduced class separation) was generated. The resulting realistic model predictions were saved to a new, dedicated JSON data file for the PR curve tests, ensuring the visual baseline tests correctly represent expected outputs.

Key Changes

  • New Realistic Test Data: Added plotly_models_pr_curve.json which contains simulated data with realistic PR threshold trade-offs for Decision Tree, Random Forest, and Gradient Boosting models.
  • Fixture Updates: Introduced plotly_models_pr_curve_dict fixture in test_curves.py to load the new dataset exclusively for Precision-Recall tests. The existing plotly_models.json is preserved to avoid breaking current ROC curve baseline tests.
  • Refactoring: Refactored test_plotly_graph_method_shape_mismatch using pytest.mark.parametrize to dynamically handle validation against both data files without code duplication.
  • Linting: Code was formatted and linted using ruff to comply with the project standards.

Verification

  • Baseline images for PR curves have been regenerated locally by the developer and confirmed to display realistic, descending shapes (top-left to bottom-right).
  • All test_curves.py unit tests pass successfully.
  • Code passes ruff check and ruff format.

- Added a new fixture `plotly_models_pr_curve_dict` to load precision-recall curve data from a JSON file.
- Updated tests for plotting precision-recall curves to use the new fixture, ensuring consistency in data handling.
- Modified baseline images for precision-recall curve tests to reflect recent changes in plotting behavior and annotations.

These changes enhance the robustness of the precision-recall curve testing framework and ensure accurate visual comparisons.
@idanmoradarthas idanmoradarthas self-assigned this Apr 22, 2026
@idanmoradarthas idanmoradarthas linked an issue Apr 22, 2026 that may be closed by this pull request
8 tasks
@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

- Updated the `plot_precision_recall_curve_with_thresholds_annotations` function to handle NaN values in thresholds, ensuring that the displayed probability annotations are clear and informative.
- Modified the text formatting for annotations to indicate 'N/A' for NaN probabilities, improving the clarity of the visual output.

These changes enhance the usability of the precision-recall curve visualization by providing more accurate and user-friendly annotations.
@idanmoradarthas
idanmoradarthas merged commit dbdd2f1 into master Apr 24, 2026
13 checks passed
@idanmoradarthas
idanmoradarthas deleted the 100-improve-test-data-for-precision-recall-curve-to-show-realistic-shape branch April 24, 2026 03:27
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

Successfully merging this pull request may close these issues.

Improve Test Data for Precision-Recall Curve to Show Realistic Shape

1 participant