Skip to content

True Positive and Negative rates in multiclosure weighted fits#2258

Merged
comane merged 27 commits into
masterfrom
nsigma_multiclosure_tpr_tnr
Apr 28, 2025
Merged

True Positive and Negative rates in multiclosure weighted fits#2258
comane merged 27 commits into
masterfrom
nsigma_multiclosure_tpr_tnr

Conversation

@comane
Copy link
Copy Markdown
Member

@comane comane commented Jan 17, 2025

Module for computation of True Positive and Negative rates for flagging a dataset as inconsistent.

When the fit is weighted TPR and TNR are computed taking into account whether adding the weight has deteriorated the overall fit quality.

  • Add arXiv reference once paper is out
  • notation of various sets should be consistent with the one used in the paper (currently S2 <-> S3)
  • polish plotting functions

@comane comane changed the title [WIP] True Positive and Negative rates in multiclosure weighted fits True Positive and Negative rates in multiclosure weighted fits Jan 18, 2025
@comane comane force-pushed the nsigma_multiclosure_tpr_tnr branch from a3aed71 to a569fd6 Compare January 23, 2025 11:39
@comane comane force-pushed the nsigma_multiclosure_tpr_tnr branch from 93b23f0 to b46f020 Compare March 26, 2025 15:12
Copy link
Copy Markdown
Member

@scarlehoff scarlehoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is mostly ok. The only thing is that, if possible, I'd try to trim down the helpers since some of the functionality is already in results.py (or, the one that is not, would be better suited as enhancements there).

Comment thread validphys2/src/validphys/closuretest/multiclosure_nsigma.py
Comment thread validphys2/src/validphys/closuretest/multiclosure_nsigma_helpers.py
Comment thread validphys2/src/validphys/closuretest/__init__.py Outdated
Comment thread validphys2/src/validphys/closuretest/multiclosure_nsigma.py Outdated
Comment thread validphys2/src/validphys/closuretest/multiclosure_nsigma.py Outdated

@property
def reduced(self):
return self.value / self.ndata
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already Chi2Data in results... I wonder whether it'd be better to extend that one? Or maybe use a different name here?

The difference is that this one holds the dataset only while the other holds a whole result object.

(in any case docstr needed)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What name would you go for? Would DatasetChi2 work for you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But also, I think it should be in results?

Btw, this is a case (and the one below) where there a clashes with other parts of the code generated by the import *.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one below yes, but CentralChi2Data is only defined in multiclosure to my knowledge

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right, the function there is central_chi2 instead

Comment thread validphys2/src/validphys/closuretest/multiclosure_nsigma_helpers.py Outdated

value = calc_chi2(sqrt_covmat, diff)
ndata = len(central_predictions)
return CentralChi2Data(value=value, ndata=ndata, dataset=dataset)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test it because I'm not 100% sure (maybe you are doing something in the multiclosure that will break this) but in principle this function could just depend on abs_chi2_data which would automatically get the predictions, the data and the compute the chi2.

Comment thread validphys2/src/validphys/closuretest/multiclosure_nsigma_helpers.py Outdated
Comment thread validphys2/examples/true_pos_neg_closuretests.yaml
@comane comane force-pushed the nsigma_multiclosure_tpr_tnr branch from 6d31329 to 13c6ec9 Compare April 25, 2025 08:00
@comane
Copy link
Copy Markdown
Member Author

comane commented Apr 25, 2025

Hi @scarlehoff, thank you very much for your review comments.

I should have addressed most of them now.

If you prefer I can also move the CentralChi2Data function to results.py

Comment thread validphys2/src/validphys/closuretest/__init__.py
Co-authored-by: Juan M. Cruz-Martinez <juacrumar@lairen.eu>
@comane comane merged commit 0e5cb4c into master Apr 28, 2025
11 checks passed
@comane comane deleted the nsigma_multiclosure_tpr_tnr branch April 28, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants