/
api.jl
30 lines (24 loc) · 1.3 KB
/
api.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#todo note `check` is called `_check` in MLJBase, but not public
#todo the way class_weights are specified is breaking!
#todo change `w` -> `weights`
"""
measurements(measure, ŷ, y[, weights, class_weights::AbstractDict])
Return a vector of measurements, one for each observation in `y`, rather than a single
aggregated measurement. Otherwise the behavior is the same as calling the measure directly
on data.
# New implementations
Overloading this function for new measure types is optional. A fallback returns the
aggregated measure, repeated `n` times, where `n = MLUtils.numobs(y)` (which falls back to
`length(y)` if `numobs` is not implemented). It is not typically necessary to overload
`measurements` for wrapped measures. All [`multimeasure`](@ref)s provide the obvious
fallback and other wrappers simply forward the `measurements` method of the atomic
measure. If overloading, use the following signatures:
$API.measurements(measure::SomeMeasureType, ŷ, y)
$API.measurements(measure::SomeMeasureType, ŷ, weights)
$API.measurements(measure::SomeMeasureType, ŷ, class_weights::AbstractDict)
$API.measurements(measure::SomeMeasureType, ŷ, weights, class_weights)
"""
function measurements(measure, yhat, y, args...)
m = measure(yhat, y, args...)
fill(m, MLUtils.numobs(y))
end