Skip to content

Commit 4e2bf96

Browse files
committed
change flawed test (described in #14)
1 parent 0613646 commit 4e2bf96

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

test/parameters.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@
9292
ranges = [r1, (r2, Uniform), (r3, d3), r4]
9393
state = PSO.initialize(rng, ranges, n)
9494
PSO.retrieve!(rng, state)
95-
@test state.parameters == (
96-
["a", "a", "c"],
97-
[553, 250, 375],
98-
[3.9372495283243105, 3.6569395920512977, 3.6354556967115146],
99-
[-0.8067647f0, 0.4209916f0, 0.6736019f0]
100-
)
95+
params = state.parameters
96+
@test params[1] == ["a", "a", "c"]
97+
@test params[2] [553, 250, 375]
98+
@test params[3] [3.9372495283243105, 3.6569395920512977, 3.6354556967115146]
99+
@test params[4] [-0.8067647f0, 0.4209916f0, 0.6736019f0]
101100
end
102-
end
101+
end

test/strategies/adaptive.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ end
7575
@test c2 1.8 # increase social
7676
end
7777

78-
for acceleration in (CPU1(), CPUProcesses(), CPUThreads())
78+
const losses = []
79+
const modes = [CPU1(), CPUProcesses(), CPUThreads()]
80+
81+
for acceleration in modes
7982
@testset "EvoTree Tuning with AdaptiveParticleSwarm and $(typeof(acceleration))" begin
8083
rng = StableRNG(123)
8184
features = rand(rng, 10_000) .* 5 .- 2
@@ -115,9 +118,17 @@ for acceleration in (CPU1(), CPUProcesses(), CPUThreads())
115118
fit!(mach, verbosity=0)
116119
rep = report(mach)
117120
best_loss = rep.best_history_entry.measurement[1]
121+
push!(losses, best_loss)
122+
123+
@show best_loss baseline_best_loss
124+
125+
# There is no reason to expect PSO to be better than
126+
# RandomSearch, but they should give results with similar order
127+
# of magnitude:
118128

119-
# Compare with random search result with the same settings
120-
@test best_loss < baseline_best_loss ||
121-
isapprox(best_loss, baseline_best_loss; atol=1e-3)
129+
@test abs(best_loss/baseline_best_loss - 1) < 1
122130
end
123-
end
131+
end
132+
133+
println("Adaptive PSO losses (see Issue #14):")
134+
(; modes, losses) |> MLJBase.pretty

0 commit comments

Comments
 (0)