Skip to content

Commit 5c0d205

Browse files
authored
Merge pull request #4 from JuliaAI/dev
For a 0.1.0 release, take II
2 parents 0c7cd96 + 581fb10 commit 5c0d205

File tree

4 files changed

+33
-21
lines changed

4 files changed

+33
-21
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ A Julia package for building production-ready measures (metrics) for statistics
66
[![Coverage](https://codecov.io/gh/JuliaAI/StatisticalMeasuresBase.jl/branch/master/graph/badge.svg)](https://codecov.io/github/JuliaAI/StatisticalMeasuresBase.jl?branch=master)
77
[![Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliaai.github.io/StatisticalMeasuresBase.jl/dev/)
88

9+
Related:
10+
[StatisticalMeasures.jl](https://github.com/JuliaAI/StatisticalMeasuresBase.jl/actions).
11+
912

1013
## The main idea
1114

@@ -63,3 +66,5 @@ julia> measurements(multitarget_L1, t̂, t, weights)
6366
9.0
6467
```
6568

69+
See [here](https://juliaai.github.io/StatisticalMeasuresBase.jl/dev/) for in-depth
70+
documentation.

src/constants.jl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@ const DOC_SCITYPES =
2020
"Scientific types can be imported from "*
2121
"ScientificTypesBase.jl; see also the ScientificTypes.jl documentation. "
2222

23-
ERR_BAD_FUNCTION(f) = ErrorException(
24-
"It looks like you're trying to use the function $f as an aggregating "*
25-
"measure but have not flagged it as such. Consider declaring "*
26-
"`StatisticalMeasuresBase.can_report_unaggregated(::typeof($f)) = true`."
27-
)
28-
29-
ERR_NOT_A_MEASURE(measure) = ArgumentError(
30-
"$measure is not a measure, as defined in by StatisticalMeasuresBase.jl. "*
31-
"Did you maybe pass a type instead of an instance? "
32-
)
33-
3423
ERR_NOT_CONVERTIBLE = ArgumentError("Not convertibe to a $API.jl measure. ")
3524

3625
const ERR_UNSUPPORTED_BY_FUSSY = ArgumentError(
@@ -86,8 +75,3 @@ ERR_BAD_TRAIT(trait) = ArgumentError(
8675
"$trait is not an overloadable trait. Only these traits can be overloaded: "*
8776
"$OVERLOADABLE_TRAITS_LIST. "
8877
)
89-
90-
ERR_MEASUREMENTS_UNSUPPORTED(measure) = ArgumentError(
91-
"The `measurements` cannot be called on $measure as "*
92-
"`$API.consumes_multiple_observations(measure)` is `false`. "
93-
)

src/supports_missings_measure.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ call(measure::SupportsMissingsMeasure, ::Missing, ::Missing, args...) = missing
2424
call(measure::SupportsMissingsMeasure, ::Missing, y, args...) = missing
2525
call(measure::SupportsMissingsMeasure, yhat, ::Missing, args...) = missing
2626

27-
measurments(measure::SupportsMissingsMeasure, yhat, y, args...) =
28-
measurments(atom(measure), yhat, y, args...)
29-
measurments(measure::SupportsMissingsMeasure, ::Missing, ::Missing, args...) =
27+
measurements(measure::SupportsMissingsMeasure, yhat, y, args...) =
28+
measurements(atom(measure), yhat, y, args...)
29+
measurements(measure::SupportsMissingsMeasure, ::Missing, ::Missing, args...) =
3030
missing
31-
measurments(measure::SupportsMissingsMeasure, ::Missing, y, args...) =
31+
measurements(measure::SupportsMissingsMeasure, ::Missing, y, args...) =
3232
missing
33-
measurments(measure::SupportsMissingsMeasure, yhat, ::Missing, args...) =
33+
measurements(measure::SupportsMissingsMeasure, yhat, ::Missing, args...) =
3434
missing
3535

3636

test/supports_missings_measure.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
measure = API.supports_missings_measure(LPLossOnScalars())
2+
rng = srng(123)
23

34
@testset "calling" begin
45
@test ismissing(measure(1.0, missing))
@@ -7,6 +8,28 @@ measure = API.supports_missings_measure(LPLossOnScalars())
78
@test measure(1.0, 4.5) == lploss(1.0, 4.5)
89
end
910

11+
atom = LPLossOnVectors()
12+
measure = API.supports_missings_measure(atom)
13+
y = [1 ,2, 3]
14+
yhat = rand(rng, 3)
15+
weights = rand(3)
16+
class_weights = Dict(1=>rand(rng), 2=>rand(rng), 3=>rand(rng))
17+
18+
@testset "measurements" begin
19+
ms = measurements(measure, [1, missing, 2], [missing, 1, 2])
20+
@test ismissing(ms[1])
21+
@test ismissing(ms[2])
22+
@test !ismissing(ms[3])
23+
@test measurements(measure, yhat, y)
24+
measurements(atom, yhat, y)
25+
@test measurements(measure, yhat, y, weights)
26+
measurements(atom, yhat, y, weights)
27+
@test measurements(measure, yhat, y, class_weights)
28+
measurements(atom, yhat, y, class_weights)
29+
@test measurements(measure, yhat, y, weights, class_weights)
30+
measurements(atom, yhat, y, weights, class_weights)
31+
end
32+
1033
atom = TraitTester(0)
1134
measure = supports_missings_measure(atom)
1235

0 commit comments

Comments
 (0)