|
93 | 93 | end |
94 | 94 |
|
95 | 95 | @testset "binary classification" begin |
96 | | - # probabilities and boolean targets |
| 96 | + # probabilities and corresponding full categorical distribution |
97 | 97 | p, testp = rand(2) |
98 | | - y, testy = rand(Bool, 2) |
99 | | - scale = rand() |
100 | | - kernel = SqExponentialKernel() ∘ ScaleTransform(scale) |
101 | | - val = unsafe_ucme_eval(kernel ⊗ WhiteKernel(), p, y, testp, testy) |
102 | | - @test unsafe_ucme_eval(kernel ⊗ WhiteKernel2(), p, y, testp, testy) ≈ val |
103 | | - @test unsafe_ucme_eval(TensorProduct2(kernel, WhiteKernel()), p, y, testp, testy) ≈ |
104 | | - val |
105 | | - @test unsafe_ucme_eval(TensorProduct2(kernel, WhiteKernel2()), p, y, testp, testy) ≈ |
106 | | - val |
107 | | - |
108 | | - # corresponding values and kernel for full categorical distribution |
109 | 98 | pfull = [p, 1 - p] |
110 | | - yint = 2 - y |
111 | 99 | testpfull = [testp, 1 - testp] |
112 | | - testyint = 2 - testy |
| 100 | + |
| 101 | + # kernel for probabilities and corresponding one for full categorical distributions |
| 102 | + scale = rand() |
| 103 | + kernel = SqExponentialKernel() ∘ ScaleTransform(scale) |
113 | 104 | kernelfull = SqExponentialKernel() ∘ ScaleTransform(scale / sqrt(2)) |
114 | 105 |
|
115 | | - @test unsafe_ucme_eval( |
116 | | - kernelfull ⊗ WhiteKernel(), pfull, yint, testpfull, testyint |
117 | | - ) ≈ val |
118 | | - @test unsafe_ucme_eval( |
119 | | - kernelfull ⊗ WhiteKernel2(), pfull, yint, testpfull, testyint |
120 | | - ) ≈ val |
121 | | - @test unsafe_ucme_eval( |
122 | | - TensorProduct2(kernelfull, WhiteKernel()), pfull, yint, testpfull, testyint |
123 | | - ) ≈ val |
124 | | - @test unsafe_ucme_eval( |
125 | | - TensorProduct2(kernelfull, WhiteKernel2()), pfull, yint, testpfull, testyint |
126 | | - ) ≈ val |
| 106 | + # for different targets |
| 107 | + for y in (true, false), testy in (true, false) |
| 108 | + # check values for probabilities |
| 109 | + val = unsafe_ucme_eval(kernel ⊗ WhiteKernel(), p, y, testp, testy) |
| 110 | + @test unsafe_ucme_eval(kernel ⊗ WhiteKernel2(), p, y, testp, testy) ≈ val |
| 111 | + @test unsafe_ucme_eval( |
| 112 | + TensorProduct2(kernel, WhiteKernel()), p, y, testp, testy |
| 113 | + ) ≈ val |
| 114 | + @test unsafe_ucme_eval( |
| 115 | + TensorProduct2(kernel, WhiteKernel2()), p, y, testp, testy |
| 116 | + ) ≈ val |
| 117 | + |
| 118 | + # check values for categorical distributions |
| 119 | + yint = 2 - y |
| 120 | + testyint = 2 - testy |
| 121 | + @test unsafe_ucme_eval( |
| 122 | + kernelfull ⊗ WhiteKernel(), pfull, yint, testpfull, testyint |
| 123 | + ) ≈ val |
| 124 | + @test unsafe_ucme_eval( |
| 125 | + kernelfull ⊗ WhiteKernel2(), pfull, yint, testpfull, testyint |
| 126 | + ) ≈ val |
| 127 | + @test unsafe_ucme_eval( |
| 128 | + TensorProduct2(kernelfull, WhiteKernel()), pfull, yint, testpfull, testyint |
| 129 | + ) ≈ val |
| 130 | + @test unsafe_ucme_eval( |
| 131 | + TensorProduct2(kernelfull, WhiteKernel2()), pfull, yint, testpfull, testyint |
| 132 | + ) ≈ val |
| 133 | + end |
127 | 134 | end |
128 | 135 |
|
129 | 136 | @testset "multi-class classification" begin |
|
140 | 147 |
|
141 | 148 | @test unsafe_ucme_eval(kernel ⊗ WhiteKernel2(), p, y, testp, testy) ≈ val |
142 | 149 | @test unsafe_ucme_eval(TensorProduct2(kernel, WhiteKernel()), p, y, testp, testy) ≈ |
143 | | - val |
| 150 | + val |
144 | 151 | @test unsafe_ucme_eval(TensorProduct2(kernel, WhiteKernel2()), p, y, testp, testy) ≈ |
145 | | - val |
| 152 | + val |
146 | 153 | end |
147 | 154 | end |
0 commit comments