API

Diagrams

Makie

ReliabilityDiagrams.reliabilityFunction
reliability(probabilities, frequencies; deviation=true, kwargs...)
reliability(probabilities, frequencies, low_high; deviation=true, kwargs...)
reliability(probabilities, frequencies, low, high; deviation=true, kwargs...)

Plot a reliability diagram of the observed frequencies versus the predicted probabilities, optionally with consistency bars ranging from low to high for each probability.

If deviation is true (default), the difference frequencies - probabilities is plotted versus probabilities. This can be helpful for inspecting how closely the observed frequencies match the predicted probabilities.

Attributes

Available attributes and their defaults for Combined{ReliabilityDiagrams.reliability} are:

  barscolor         :black
  barscolormap      :viridis
  barscolorrange    MakieCore.Automatic()
  barslinewidth     1.5
  barsvisible       true
  barswhiskerwidth  0
  color             :black
  colormap          :viridis
  colorrange        MakieCore.Automatic()
  cycle             [:color]
  deviation         true
  inspectable       true
  linestyle         "nothing"
  linewidth         1.5
  marker            :circle
  markercolor       :black
  markercolormap    :viridis
  markercolorrange  MakieCore.Automatic()
  markersize        12
  markervisible     true
  strokecolor       :black
  strokewidth       0
  visible           true

General Axis Keywords

  • xlabel: Label of x axis (default: confidence)
  • ylabel: Label of y axis (default: if deviation == true, then empirical deviation, otherwise empirical frequency)

Examples

julia> probabilities = sort(rand(10));

julia> frequencies = rand(10);

julia> reliability(probabilities, frequencies);

julia> # plot frequencies instead of deviations
       reliability(probabilities, frequencies; deviation=false);

julia> # use different colors for markers
       reliability(probabilities, frequencies; markercolor=:red);

julia> # random consistency bars
       low = max.(0, probabilities .- rand.());

julia> high = min.(1, probabilities .+ rand.());

julia> # plot pre-computed consistency bars
       reliability(probabilities, frequencies, low, high);

julia> # alternatively consistency bars can be specified as vector of tuples
       reliability(probabilities, frequencies, map(tuple, low, high));

References

Bröcker, J. and Smith, L.A. (2007). Increasing the reliability of reliability diagrams. Weather and forecasting, 22(3), pp. 651-661.

source
reliability(
    probabilities::AbstractVector{<:Real},
    outcomes::AbstractVector{Bool};
    binning=EqualMass(),
    consistencybars=ConsistencyBars(),
    kwargs...,
)

Plot a reliability diagram of the observed frequencies versus the mean probabilities in different clusters together with a set of consistency bars.

Optionally, the binning algorithm that is used to form the clusters and the consistency bars can be configured with the binning and consistencybars keyword arguments. If consistencybars === nothing, then no consistency bars are computed.

Examples

julia> probabilities = rand(10);

julia> outcomes = rand(Bool, 10);

julia> # default binning and consistency bars
       reliability(probabilities, outcomes);

julia> # custom options: without consistency bars
       reliability(probabilities, outcomes; consistencybars=nothing);

See also: EqualMass, EqualSize, ConsistencyBars

source

Example

using ReliabilityDiagrams
using CairoMakie

probabilities = rand(100)
outcomes = rand(100) .< probabilities
reliability(probabilities, outcomes)

reliability example

lines([0, 1], [0, 1]; color=:black)
reliability!(probabilities, outcomes; deviation=false)

reliability example nodeviation

reliability(probabilities, outcomes; consistencybars=nothing)

reliability example noconsistencybars

reliability(probabilities, outcomes; binning=EqualSize())

reliability example equalsize

Plots

ReliabilityDiagrams.reliabilityplotFunction
reliabilityplot(probabilities, frequencies; deviation=true, kwargs...)
reliabilityplot(probabilities, frequencies, low_high; deviation=true, kwargs...)
reliabilityplot(probabilities, frequencies, low, high; deviation=true, kwargs...)

Plot a reliability diagram of the observed frequencies versus the predicted probabilities, optionally with consistency bars ranging from low to high for each probability.

If deviation is true (default), the difference frequencies - probabilities is plotted versus probabilities. This can be helpful for inspecting how closely the observed frequencies match the predicted probabilities.

Examples

julia> probabilities = sort(rand(10));

julia> frequencies = rand(10);

julia> reliabilityplot(probabilities, frequencies);

julia> # plot frequencies instead of deviations
       reliabilityplot(probabilities, frequencies; deviation=false);

julia> # use different colors for markers
       reliabilityplot(probabilities, frequencies; markercolor=:red);

julia> # random consistency bars
       low = max.(0, probabilities .- rand.());

julia> high = min.(1, probabilities .+ rand.());

julia> # plot pre-computed consistency bars
       reliabilityplot(probabilities, frequencies, low, high);

julia> # alternatively consistency bars can be specified as vector of tuples
       reliabilityplot(probabilities, frequencies, map(tuple, low, high));

References

Bröcker, J. and Smith, L.A. (2007). Increasing the reliability of reliability diagrams. Weather and forecasting, 22(3), pp. 651-661.

source
reliabilityplot(
    probabilities::AbstractVector{<:Real},
    outcomes::AbstractVector{Bool};
    binning=EqualMass(),
    consistencybars=ConsistencyBars(),
    kwargs...,
)

Plot a reliability diagram of the observed frequencies versus the mean probabilities in different clusters together with a set of consistency bars.

Optionally, the binning algorithm that is used to form the clusters and the consistency bars can be configured with the binning and consistencybars keyword arguments. If consistencybars === nothing, then no consistency bars are computed.

Examples

julia> probabilities = rand(10);

julia> outcomes = rand(Bool, 10);

julia> # default binning and consistency bars
       reliabilityplot(probabilities, outcomes);

julia> # custom options: without consistency bars
       reliabilityplot(probabilities, outcomes; consistencybars=nothing);

See also: EqualMass, EqualSize, ConsistencyBars

source

Example

using ReliabilityDiagrams
using Plots

probabilities = rand(100)
outcomes = rand(100) .< probabilities
reliabilityplot(probabilities, outcomes)

reliabilityplot example

plot([0, 1], [0, 1])
reliabilityplot!(probabilities, outcomes; deviation=false)

reliabilityplot example nodeviation

reliabilityplot(probabilities, outcomes; consistencybars=nothing)

reliabilityplot example noconsistencybars

reliabilityplot(probabilities, outcomes; binning=EqualSize())

reliabilityplot example equalsize

Binning algorithms

Consistency bars

ReliabilityDiagrams.ConsistencyBarsType
ConsistencyBars(; samples::Int=1_000, coverage::Real=0.95)

Create consistency bars that cover a proportion of coverage samples obtained by consistency resampling with samples resampling steps.

References

Bröcker, J. and Smith, L.A. (2007). Increasing the reliability of reliability diagrams. Weather and forecasting, 22(3), pp. 651-661.

source