StatisticalMeasuresBase.jl

A Julia package for building production-ready measures (metrics) for statistics and machine learning
Author JuliaAI
Popularity
8 Stars
Updated Last
1 Year Ago
Started In
May 2023

StatisticalMeasuresBase.jl

A Julia package for building production-ready measures (metrics) for statistics and machine learning

Build Status Coverage Docs

Related: StatisticalMeasures.jl

List of Julia packages providing metrics.

The main idea

Here's an example of a simple statistical measure that can be applied to a pair of scalars:

l1(ŷ, y) = abs(ŷ - y)
y = 5 # ground truth= 2 # prediction

julia> l1(ŷ, y)
3

Wrappers provided in this package extend the functionality of such measures. For example:

using StatisticalMeasuresBase
L1 = multimeasure(supports_missings_measure(l1), mode=Sum())
y = [5, 6, missing]
ŷ = [6, 8, 7]
weights = [1, 3, 9]

julia> L1(ŷ, y, weights)  1*l1(6, 5) + 3*l1(8, 6)
true
multitarget_L1 = multimeasure(L1, transform=veccollect)
# 3 observations (last index is observation index):
y = [1 2 3; 2 4 6]
ŷ = [2 3 4; 4 6 8]

julia> multitarget_L1(ŷ, y, weights)
39
using DataFrames
df    = DataFrame(y', :auto)
df̂    = DataFrame(ŷ', :auto)

julia> multitarget_L1(df̂, df, weights)
39

Generate measurements for each observation with the measurements method:

julia> measurements(multitarget_L1, df̂, df, weights)
3-element Vector{Int64}:
  3
  9
 27

See here for in-depth documentation.