sorbetto.performance.distribution package

class sorbetto.performance.distribution.AbstractDistributionOfTwoClassClassificationPerformances(name)[source]

Bases: ABC

This is the base class for all distributions of two-class classification performances.

abstract drawAtRandom(numPerformances: int) FiniteSetOfTwoClassClassificationPerformances[source]
abstract drawOneAtRandom() TwoClassClassificationPerformance[source]
abstract getMean() TwoClassClassificationPerformance[source]
property name: str
class sorbetto.performance.distribution.UniformDistributionOfTwoClassClassificationPerformances(name)[source]

Bases: AbstractDistributionOfTwoClassClassificationPerformances

All instances of this class represent the uniform distribution of two-class classification performances, over the whole performance space. This is equivalent to a Dirichlet distribution with all concentration parameters set to one.

See https://en.wikipedia.org/wiki/Continuous_uniform_distribution See https://en.wikipedia.org/wiki/Dirichlet_distribution

drawAtRandom(numPerformances) FiniteSetOfTwoClassClassificationPerformances[source]
drawOneAtRandom() TwoClassClassificationPerformance[source]

Draw a two-class classification performances at random, uniformy, in the set of all performances.

Returns:

the performance.

Return type:

TwoClassClassificationPerformance

getMean() TwoClassClassificationPerformance[source]

Computes the mean of the distribution.

sampleOnRegularGrid(grid_size: int) FiniteSetOfTwoClassClassificationPerformances[source]

_summary_

Parameters:

grid_size (int) – _description_

Returns:

_description_

Return type:

FiniteSetOfTwoClassClassificationPerformances

Yields:

Iterator[FiniteSetOfTwoClassClassificationPerformances] – _description_

class sorbetto.performance.distribution.UniformDistributionOfTwoClassClassificationPerformancesForFixedClassPriors(priorPos: float, name: str | None = None)[source]

Bases: AbstractDistributionOfTwoClassClassificationPerformances

The instances of this class represent a uniform distribution of two-class classification performances over the part of the performance space that corresponds to some given class priors. Geometricaly, this part is the intersection of the tetrahedron with a plane, and is a rectangle.

It can be shown that the True Negative Rate (TNR), the False Positive Rate (FPR), the False Negative Rate (FNR), and True Positive Rate (TPR) are all uniformly distributed random variables over [0, 1]. Moreover, the TNR (or FPR) and FNR (or TPR) are independent. In fact, TNR (or FPR) and FNR (or TPR) are the two Cartesian coordinates of a performance within the rectangle of interest.

drawAtRandom(numPerformances: int) FiniteSetOfTwoClassClassificationPerformances[source]

Draw numPerformances two-class classification performances at random, uniformy, in the performances corresponding to fixed class prios.

Parameters:

numPerformances (int) – the amount of performances to draw.

Returns:

the (multi)set.

Return type:

FiniteSetOfTwoClassClassificationPerformances

drawOneAtRandom() TwoClassClassificationPerformance[source]

Draw a two-class classification performances at random, uniformy, in the performances corresponding to fixed class prios.

Returns:

the performance.

Return type:

TwoClassClassificationPerformance

getConstraint() ConstraintFixedClassPriors[source]

Provide the constraint that corresponds to the fixed class priors.

Returns:

The constraint.

Return type:

ConstraintFixedClassPriors

getMean() TwoClassClassificationPerformance[source]

Computes the mean of the distribution.

property priorNeg: float

The prior of the negative class.

Returns:

\(\pi_- = P( \{ tn, tp \} )\)

Return type:

priorNeg

property priorPos: float

The prior of the positive class.

Returns:

\(\pi_+ = P( \{ fn, tp \} )\)

Return type:

priorPos

sampleOnRegularGrid(gridSize: int, open: bool = False) FiniteSetOfTwoClassClassificationPerformances[source]

Sample the rectangle of two-class classification performances corresponding to the fixed class priors on a regular grid of size gridSize.

Parameters:
  • gridSize (_type_) – The size of the grid.

  • open (bool, optional) – Whether the borders are excluded. Defaults to False.

Returns:

The gridSize times gridSize performances.

Return type:

FiniteSetOfTwoClassClassificationPerformances

class sorbetto.performance.distribution.UniformDistributionOfTwoClassClassificationPerformancesForFixedPredictionRates(ratePos: float, name: str | None = None)[source]

Bases: AbstractDistributionOfTwoClassClassificationPerformances

The instances of this class represent a uniform distribution of two-class classification performances over the part of the performance space that corresponds to some given prediction rates. Geometricaly, this part is the intersection of the tetrahedron with a plane, and is a rectangle.

It can be shown that the Negative Predictive Value (NPV), the False Discovery Rate (FDR), the False Omission Rate (FOR), and Posiitive Predictive Value (PPV) are all uniformly distributed random variables over [0, 1]. Moreover, the NPV (or FOR) and PPV (or FDR) are independent. In fact, NPV (or FOR) and PPV (or FDR) are the two Cartesian coordinates of a performance within the rectangle of interest.

drawAtRandom(numPerformances: int) FiniteSetOfTwoClassClassificationPerformances[source]

Draw numPerformances two-class classification performances at random, uniformy, in the performances corresponding to fixed prediction rates.

Parameters:

numPerformances (int) – the amount of performances to draw.

Returns:

the (multi)set.

Return type:

FiniteSetOfTwoClassClassificationPerformances

drawOneAtRandom() TwoClassClassificationPerformance[source]

Draw a two-class classification performances at random, uniformy, in the performances corresponding to fixed prediction rates.

Returns:

the performance.

Return type:

TwoClassClassificationPerformance

getConstraint() ConstraintFixedPredictionRates[source]

Provide the constraint that corresponds to the fixed prediction rates.

Returns:

The constraint.

Return type:

ConstraintFixedClassPriors

getMean() TwoClassClassificationPerformance[source]

Computes the mean of the distribution.

property rateNeg: float

The rate of predictions for the negative class.

Returns:

\(\tau_- = P( \{ tn, fn \} )\)

Return type:

rateNeg

property ratePos: float

The rate of predictions for the positive class.

Returns:

\(\tau_+ = P( \{ fp, tp \} )\)

Return type:

ratePos

sampleOnRegularGrid(gridSize: int, open: bool = False) FiniteSetOfTwoClassClassificationPerformances[source]

Sample the rectangle of two-class classification performances corresponding to the fixed prediction rates on a regular grid of size gridSize.

Parameters:
  • gridSize (_type_) – The size of the grid.

  • open (bool, optional) – Whether the borders are excluded. Defaults to False.

Returns:

The gridSize times gridSize performances.

Return type:

FiniteSetOfTwoClassClassificationPerformances

Submodules