Skip to content

Commit 6d29fd8

Browse files
committed
Fix deprecations and commit to vector inputs (#31)
1 parent 57e4891 commit 6d29fd8

17 files changed

+690
-580
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CalibrationTests"
22
uuid = "2818745e-0823-50c7-bc2d-405ac343d48b"
33
authors = ["David Widmann <[email protected]>"]
4-
version = "0.5.1"
4+
version = "0.5.2"
55

66
[deps]
77
CalibrationErrors = "33913031-fe46-5864-950f-100836f47845"
@@ -16,7 +16,7 @@ StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
1616
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
1717

1818
[compat]
19-
CalibrationErrors = "0.5.12"
19+
CalibrationErrors = "0.5.15"
2020
HypothesisTests = "0.8, 0.9, 0.10"
2121
KernelFunctions = "0.8.20, 0.9"
2222
Reexport = "1"

src/CalibrationTests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ include("skce/distribution_free.jl")
3030

3131
include("cme.jl")
3232

33+
include("deprecated.jl")
34+
3335
end # module

src/cme.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ struct AsymptoticCMETest{K<:Kernel,V,M,S} <: HypothesisTests.HypothesisTest
1313
statistic::S
1414
end
1515

16-
function AsymptoticCMETest(estimator::UCME, data...)
16+
function AsymptoticCMETest(
17+
estimator::UCME, predictions::AbstractVector, targets::AbstractVector
18+
)
1719
@unpack kernel, testpredictions, testtargets = estimator
1820

19-
# obtain predictions and targets
20-
predictions, targets = CalibrationErrors.predictions_targets(data...)
21-
2221
# determine number of observations and test locations
2322
nsamples = length(predictions)
2423
ntestsamples = length(testpredictions)

src/consistency.jl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ struct ConsistencyTest{E<:CalibrationErrorEstimator,P,T,V} <: HypothesisTests.Hy
99
estimate::V
1010
end
1111

12-
function ConsistencyTest(estimator::CalibrationErrorEstimator, data...)
13-
# obtain the predictions and targets
14-
predictions, targets = CalibrationErrors.predictions_targets(data...)
15-
16-
# compute the calibration error estimate
17-
estimate = calibrationerror(estimator, predictions, targets)
18-
12+
function ConsistencyTest(
13+
estimator::CalibrationErrorEstimator,
14+
predictions::AbstractVector,
15+
targets::AbstractVector,
16+
)
17+
estimate = estimator(predictions, targets)
1918
return ConsistencyTest(estimator, predictions, targets, estimate)
2019
end
2120

@@ -102,9 +101,7 @@ function consistency_resampling_ccdf_direct(
102101
end
103102

104103
# evaluate the calibration error
105-
resampledestimate = calibrationerror(
106-
estimator, resampledpredictions, resampledtargets
107-
)
104+
resampledestimate = estimator(resampledpredictions, resampledtargets)
108105

109106
# check if the estimate for the resampled data is ≥ the original estimate
110107
if resampledestimate estimate
@@ -154,9 +151,7 @@ function consistency_resampling_ccdf_alias(
154151
end
155152

156153
# evaluate the calibration error
157-
resampledestimate = calibrationerror(
158-
estimator, resampledpredictions, resampledtargets
159-
)
154+
resampledestimate = estimator(resampledpredictions, resampledtargets)
160155

161156
# check if the estimate for the resampled data is ≥ the original estimate
162157
if resampledestimate estimate

src/deprecated.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@deprecate ConsistencyTest(estimator::CalibrationErrorEstimator, data...) ConsistencyTest(
2+
estimator, CalibrationErrors.predictions_targets(data...)...
3+
)
4+
5+
@deprecate DistributionFreeSKCETest(estimator::SKCE, data...; kwargs...) DistributionFreeSKCETest(
6+
estimator, CalibrationErrors.predictions_targets(data...)...; kwargs...
7+
)
8+
9+
@deprecate AsymptoticSKCETest(skce::UnbiasedSKCE, data...) AsymptoticSKCETest(
10+
skce.kernel, data...
11+
)
12+
@deprecate AsymptoticSKCETest(kernel::Kernel, data...) AsymptoticSKCETest(
13+
kernel, CalibrationErrors.predictions_targets(data...)...
14+
)
15+
16+
@deprecate AsymptoticBlockSKCETest(skce::BlockUnbiasedSKCE, data...) AsymptoticBlockSKCETest(
17+
skce.kernel, skce.blocksize, data...
18+
)
19+
@deprecate AsymptoticBlockSKCETest(kernel::Kernel, blocksize::Int, data...) AsymptoticBlockSKCETest(
20+
kernel, blocksize, CalibrationErrors.predictions_targets(data...)...
21+
)
22+
23+
@deprecate AsymptoticCMETest(estimator::UCME, data...) AsymptoticCMETest(
24+
estimator, CalibrationErrors.predictions_targets(data...)...
25+
)

src/skce/asymptotic.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@doc raw"""
2-
AsymptoticSKCETest(kernel::Kernel, data...)
3-
AsymptoticSKCETest(skce::UnbiasedSKCE, data...)
2+
AsymptoticSKCETest(kernel::Kernel, predictions, targets)
43
54
Calibration hypothesis test based on the unbiased estimator of the squared kernel
65
calibration error (SKCE) with quadratic sample complexity.
@@ -72,12 +71,9 @@ struct AsymptoticSKCETest{K<:Kernel,E,V,M} <: HypothesisTests.HypothesisTest
7271
kernelmatrix::M
7372
end
7473

75-
AsymptoticSKCETest(skce::UnbiasedSKCE, data...) = AsymptoticSKCETest(skce.kernel, data...)
76-
77-
function AsymptoticSKCETest(kernel::Kernel, data...)
78-
# obtain the predictions and targets
79-
predictions, targets = CalibrationErrors.predictions_targets(data...)
80-
74+
function AsymptoticSKCETest(
75+
kernel::Kernel, predictions::AbstractVector, targets::AbstractVector
76+
)
8177
# compute the calibration error estimate, the test statistic, and the kernel matrix
8278
estimate, statistic, kernelmatrix = estimate_statistic_kernelmatrix(
8379
kernel, predictions, targets

src/skce/asymptotic_block.jl

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@ struct AsymptoticBlockSKCETest{K<:Kernel,E,S,Z} <: HypothesisTests.ZTest
1313
z::Z
1414
end
1515

16-
function AsymptoticBlockSKCETest(skce::BlockUnbiasedSKCE, data...)
17-
return AsymptoticBlockSKCETest(skce.kernel, skce.blocksize, data...)
18-
end
19-
20-
function AsymptoticBlockSKCETest(kernel::Kernel, blocksize::Int, data...)
21-
# obtain predictions and targets
22-
predictions, targets = CalibrationErrors.predictions_targets(data...)
23-
16+
function AsymptoticBlockSKCETest(
17+
kernel::Kernel, blocksize::Int, predictions::AbstractVector, targets::AbstractVector
18+
)
2419
# obtain number of samples
2520
nsamples = length(predictions)
2621
nsamples blocksize || error("there must be at least ", blocksize, " samples")
@@ -32,9 +27,7 @@ function AsymptoticBlockSKCETest(kernel::Kernel, blocksize::Int, data...)
3227
# evaluate U-statistic of the first block
3328
istart = 1
3429
iend = blocksize
35-
x = CalibrationErrors.unbiasedskce(
36-
kernel, view(predictions, istart:iend), view(targets, istart:iend)
37-
)
30+
x = UnbiasedSKCE(kernel)(view(predictions, istart:iend), view(targets, istart:iend))
3831

3932
# initialize the estimate and the sum of squares
4033
estimate = x / 1
@@ -45,9 +38,7 @@ function AsymptoticBlockSKCETest(kernel::Kernel, blocksize::Int, data...)
4538
# evaluate U-statistic
4639
istart += blocksize
4740
iend += blocksize
48-
x = CalibrationErrors.unbiasedskce(
49-
kernel, view(predictions, istart:iend), view(targets, istart:iend)
50-
)
41+
x = UnbiasedSKCE(kernel)(view(predictions, istart:iend), view(targets, istart:iend))
5142

5243
# update the estimate
5344
Δestimate = x - estimate

src/skce/distribution_free.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ struct DistributionFreeSKCETest{E<:SKCE,B,V} <: HypothesisTests.HypothesisTest
99
estimate::V
1010
end
1111

12-
function DistributionFreeSKCETest(estimator::SKCE, data...; bound=uniformbound(estimator))
13-
# obtain the predictions and targets
14-
predictions, targets = CalibrationErrors.predictions_targets(data...)
15-
16-
# compute the calibration error estimate
17-
estimate = calibrationerror(estimator, predictions, targets)
18-
12+
function DistributionFreeSKCETest(
13+
estimator::SKCE,
14+
predictions::AbstractVector,
15+
targets::AbstractVector;
16+
bound=uniformbound(estimator),
17+
)
18+
estimate = estimator(predictions, targets)
1919
return DistributionFreeSKCETest(estimator, bound, length(predictions), estimate)
2020
end
2121

test/Project.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ CalibrationErrors = "33913031-fe46-5864-950f-100836f47845"
33
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
44
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
55
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
6-
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
76
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
87
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
9-
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
108
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
119

1210
[compat]
13-
CalibrationErrors = "0.5.12"
11+
CalibrationErrors = "0.5.15"
1412
Distributions = "0.23, 0.24"
1513
JuliaFormatter = "0.13"
16-
SafeTestsets = "0.0"
1714
StatsBase = "0.33"
18-
StatsFuns = "0.9"
1915
julia = "1.3"

0 commit comments

Comments
 (0)