Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable Elimination #238

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

naseweisssss
Copy link
Collaborator

No description provided.

@coveralls
Copy link

coveralls commented Nov 18, 2024

Pull Request Test Coverage Report for Build 11942739972

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 93 (0.0%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-3.3%) to 70.92%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/experimental/ProbabilisticGraphicalModels/bayesnet.jl 0 93 0.0%
Files with Coverage Reduction New Missed Lines %
ext/JuliaBUGSMCMCChainsExt.jl 3 78.79%
Totals Coverage Status
Change from base Build 11870001725: -3.3%
Covered Lines: 1395
Relevant Lines: 1967

💛 - Coveralls

Copy link
Contributor

github-actions bot commented Nov 18, 2024

BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.5.0 to /home/runner/.bridgestan/bridgestan-2.5.0
Done!
Model dogs produces error: ErrorException("log_density() failed with exception: Exception: bernoulli_lpmf: Probability parameter is inf, but must be in the interval [0, 1] (in '/home/runner/work/JuliaBUGS.jl/JuliaBUGS.jl/benchmark/stan/bugs_examples/vol1/dogs/dogs.stan', line 37, column 6 to line 38, column 62)\n")

Model Parameter Count Data Count Stan Density Time (µs) Stan Density Gradient Time (µs) JuliaBUGS Density Time with Graph Walk (µs) JuliaBUGS Density Gradient Time with ReverseDiff.jl(compiled tape) (µs)
rats 65 150 5.5222 8.14533 66.455 84.206
pumps 12 10 0.987833 1.307 11.4015 6.4195
dogs 2 720 NA NA 171.95 147.991
seeds 26 21 2.53745 3.12244 26.369 19.747
surgical_realistic 14 12 1.22812 1.56189 15.088 8.613
magnesium 108 96 10.364 12.092 123.926 80.69
salm 22 18 2.4145 3.06122 22.201 12.6885
equiv 15 20 2.48745 3.40638 18.986 19.055
dyes 9 30 0.991862 1.33795 11.942 13.866
stacks 6 21 1.14296 1.662 18.264 16.922
epil 303 236 32.611 38.282 283.569 245.338
blockers 47 44 3.29944 3.75414 61.114 30.446
oxford 244 240 16.059 18.725 358.939 181.032
lsat 1006 5000 172.401 214.154 2122.63 1258.78
bones 33 422 72.175 89.156 421.662 186.557
mice 20 65 7.37375 9.34767 29.125 37.851
kidney 64 58 10.9905 16.44 68.2625 82.865
leuk 18 714 20.478 26.98 216.304 231.872
leukfr 40 714 23.684 31.809 239.136 281.24

for (k, v) in evidence
node_id = bn.names_to_ids[k]
dist_idx = findfirst(id -> id == node_id, bn.stochastic_ids)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change


@testset "Marginalization with Mixed Variables" begin
bn = BayesianNetwork{Symbol}()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change


# X1 ~ Normal(0, 1)
add_stochastic_vertex!(bn, :X1, Normal(0, 1), false)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change


# X2 ~ Bernoulli(0.7) [using Categorical with 2 categories]
add_stochastic_vertex!(bn, :X2, Categorical([0.3, 0.7]), false)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# X3 ~ Normal(μ = 2*X2, σ = 1)
add_stochastic_vertex!(bn, :X3, Normal(0, 1), false)
add_edge!(bn, :X2, :X3)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Umbrella Sales (X3) ~ Normal(μ(X2), 1)
# μ = 2 if no rain (X2=0), μ = 10 if rain (X2=1)
add_stochastic_vertex!(bn, :X3, Normal(0, 1), false)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

add_stochastic_vertex!(bn, :X3, Normal(0, 1), false)

add_edge!(bn, :X2, :X3)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@test result1 > 0
println("P(X3|X1) = ", result1)
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@test 0 ≤ result ≤ 1
@test isapprox(result, 0.3, atol=0.1) # Should be close to P(X2=0)=0.3
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

result_rain = variable_elimination(bn, :X3, Dict(:X2 => 1))
@test result_rain isa Number
@test result_rain > 0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants