Roc
puma.roc.Roc
#
Bases: puma.plot_base.PlotLineObject
Represent a single ROC curve and allows to calculate ratio w.r.t other ROCs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sig_eff
|
numpy.ndarray
|
Array of signal efficiencies |
required |
bkg_rej
|
numpy.ndarray
|
Array of background rejection |
required |
n_test
|
float | None
|
Number of events used to calculate the background efficiencies. For weighted samples, pass the effective sample size N_eff = (sum w)^2 / sum(w^2) instead of the raw count. By default None |
None
|
rej_class
|
str | ftag.Label
|
Rejection class, e.g. for b-tagging anc charm rejection "cjets", by default None |
None
|
signal_class
|
str | None
|
Signal class, e.g. for b-tagging "bjets", by default None |
None
|
key
|
str | None
|
Identifier for roc curve e.g. tagger, by default None |
None
|
ratio_group
|
str | None
|
Identifies the reference ROC group for ratio calculation, by default None |
None
|
use_bkg_eff
|
bool
|
Correct error calculation for background efficiency ROCs instead of background rejection, by default False |
False
|
**kwargs
|
typing.Any
|
Keyword arguments passed to |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in puma/roc.py
args_to_store
property
#
Returns the arguments that need to be stored/loaded.
Returns:
| Type | Description |
|---|---|
dict[str, typing.Any]
|
Dict with the arguments |
non_zero
property
#
Abstraction of non_zero_mask.
Returns:
| Type | Description |
|---|---|
numpy.array
|
Masked signal efficiency |
numpy.array
|
Masked background rejection |
non_zero_mask
property
#
Masking points where rejection is 0 and no signal efficiency change present.
Returns:
| Type | Description |
|---|---|
numpy.array
|
Masked indices |
binomial_error
#
Calculate binomial error of roc curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
norm
|
bool
|
If True calulate relative error, by default False |
False
|
n_test
|
float | None
|
Number of events used to calculate the background efficiencies. For weighted samples, pass N_eff = (sum w)^2 / sum(w^2). By default None |
None
|
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Binomial error |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no |
Source code in puma/roc.py
divide
#
Calculate ratio between the roc curve and another roc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roc_comp
|
puma.roc.Roc
|
Second roc curve to calculate ratio with |
required |
inverse
|
bool
|
If False the ratio is calculated |
False
|
Returns:
| Type | Description |
|---|---|
tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]
|
The signal efficiency used for the ratio calculation which is the overlapping interval of the two roc curves The ratio between the two ROCs The ratio error between the two ROCs |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the signal efficiency between the two ROCs do not match |
Source code in puma/roc.py
puma.roc.RocPlot
#
Bases: puma.plot_base.PlotBase
ROC plot class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
bool
|
Set the grid for the plots. |
True
|
**kwargs
|
typing.Any
|
Keyword arguments from |
{}
|
Source code in puma/roc.py
add_ratios
#
Calculating ratios.
Raises:
| Type | Description |
|---|---|
ValueError
|
If number of reference rocs and ratio panels don't match If no ratio classes are set |
Source code in puma/roc.py
add_roc
#
Adding puma.Roc object to figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roc_curve
|
puma.roc.Roc
|
ROC curve |
required |
key
|
str | None
|
Unique identifier for roc_curve, by default None |
None
|
reference
|
bool
|
If roc is used as reference for ratio calculation, by default False |
False
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If unique identifier key is used twice |
Source code in puma/roc.py
draw
#
Draw plotting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labelpad
|
int | None
|
Spacing in points from the axes bounding box including ticks and tick labels, by default None |
None
|
Source code in puma/roc.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | |
get_xlim_auto
#
Returns min and max efficiency values.
Returns:
| Type | Description |
|---|---|
float
|
Min and max efficiency values |
Source code in puma/roc.py
make_split_legend
#
Draw legend for the case of 2 ratios, splitting up legend into models and rejection class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handles
|
list
|
List of Line2D objects to extract info for legend |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If not 2 ratios requested |
Source code in puma/roc.py
plot_ratios
#
Plotting ratio curves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
matplotlib.pyplot.axis
|
matplotlib axis object |
required |
rej_class
|
str
|
Rejection class |
required |
Source code in puma/roc.py
plot_roc
#
Plotting roc curves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
typing.Any
|
Keyword arguments passed to plt.axis.plot |
{}
|
Returns:
| Type | Description |
|---|---|
puma.line_plot_2d.Line2D
|
matplotlib Line2D object |
Source code in puma/roc.py
set_ratio_class
#
Associate the rejection class to a ratio panel adn set the legend label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ratio_panel
|
int
|
Ratio panel either 1 or 2 |
required |
rej_class
|
str | ftag.Label
|
Rejection class associated to that panel. Either a Label instance or a string |
required |
rej_class_label
|
str | None
|
If rej_class is not a Label, this label must be given |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the rej_class is a string and rej_class_label is not defined |
Source code in puma/roc.py
set_roc_reference
#
Setting the reference roc curves used in the ratios.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Unique identifier of roc object |
required |
rej_class
|
str | ftag.Label
|
Rejection class encoded in roc curve |
required |
ratio_group
|
str
|
Ratio group this roc is reference for |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If more rejection classes are set than actual ratio panels available. |