Skip to content

Commit

Permalink
Updated tests to use standard deviation
Browse files Browse the repository at this point in the history
  • Loading branch information
ShouvikGhosh2048 committed May 6, 2024
1 parent 40894f0 commit f237be8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions test/numerical/bayesian/LinearRegression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ tests = [
for (prior, test_mean) in tests
CRRao.set_rng(StableRNG(123))
model = fit(@formula(MPG ~ HP + WT + Gear), mtcars, LinearRegression(), prior)

@test mean(predict(model, mtcars)) test_mean
prediction = predict(model, mtcars)
@test mean(prediction) - 2 * std(prediction) <= test_mean && test_mean <= mean(prediction) + 2 * std(prediction)
end

gauss_test = 20.0796026428345

CRRao.set_rng(StableRNG(123))
model = fit(@formula(MPG ~ HP + WT + Gear), mtcars, LinearRegression(), Prior_Gauss(), 30.0, [0.0,-3.0,1.0], 1000)

@test mean(predict(model, mtcars)) gauss_test
prediction = predict(model, mtcars)
@test mean(prediction) - 2 * std(prediction) <= gauss_test && gauss_test <= mean(prediction) + 2 * std(prediction)
4 changes: 2 additions & 2 deletions test/numerical/bayesian/LogisticRegression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ for (prior, prior_testcases) in tests
for (link, test_mean) in prior_testcases
CRRao.set_rng(StableRNG(123))
model = fit(@formula(Vote ~ Age + Race + Income + Educate), turnout, LogisticRegression(), link, prior)

@test mean(predict(model, turnout)) test_mean
prediction = predict(model, turnout)
@test mean(prediction) - 2 * std(prediction) <= test_mean && test_mean <= mean(prediction) + 2 * std(prediction)
end
end
4 changes: 2 additions & 2 deletions test/numerical/bayesian/NegBinomialRegression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ tests = [
for (prior, test_mean) in tests
CRRao.set_rng(StableRNG(123))
model = fit(@formula(Num ~ Target + Coop + NCost), sanction, NegBinomRegression(), prior)

@test mean(predict(model, sanction)) test_mean
prediction = predict(model, sanction)
@test mean(prediction) - 2 * std(prediction) <= test_mean && test_mean <= mean(prediction) + 2 * std(prediction)
end
4 changes: 2 additions & 2 deletions test/numerical/bayesian/PoissonRegression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ tests = [
for (prior, test_mean) in tests
CRRao.set_rng(StableRNG(123))
model = fit(@formula(Num ~ Target + Coop + NCost), sanction, PoissonRegression(), prior)

@test mean(predict(model, sanction)) test_mean
prediction = predict(model, sanction)
@test mean(prediction) - 2 * std(prediction) <= test_mean && test_mean <= mean(prediction) + 2 * std(prediction)
end

0 comments on commit f237be8

Please sign in to comment.