-
Notifications
You must be signed in to change notification settings - Fork 5
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 reimplementation #240
base: master
Are you sure you want to change the base?
Conversation
@@ -10,7 +18,9 @@ using JuliaBUGS.ProbabilisticGraphicalModels: | |||
condition!, | |||
decondition, | |||
ancestral_sampling, | |||
is_conditionally_independent | |||
is_conditionally_independent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
is_conditionally_independent, | |
is_conditionally_independent, |
Pull Request Test Coverage Report for Build 12068346100Details
💛 - Coveralls |
BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.5.0 to /home/runner/.bridgestan/bridgestan-2.5.0
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/test/experimental/ProbabilisticGraphicalModels/test_variable_elimination.jl
Line 92 in fcc4c58
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/test/experimental/ProbabilisticGraphicalModels/test_variable_elimination.jl
Line 97 in fcc4c58
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/test/experimental/ProbabilisticGraphicalModels/test_variable_elimination.jl
Line 101 in fcc4c58
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/test/experimental/ProbabilisticGraphicalModels/test_variable_elimination.jl
Line 105 in fcc4c58
[JuliaFormatter] reported by reviewdog 🐶
BitVector(), # is_stochastic | ||
Int[], # stochastic_ids | ||
Int[], # deterministic_ids | ||
Function[] # deterministic_functions - Added this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Function[] # deterministic_functions - Added this | |
Function[], # deterministic_functions - Added this |
bn::BayesianNetwork{V,T}, | ||
name::V, | ||
dist::Union{Distribution,Function}, | ||
is_observed::Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
bn::BayesianNetwork{V,T}, | |
name::V, | |
dist::Union{Distribution,Function}, | |
is_observed::Bool | |
bn::BayesianNetwork{V,T}, name::V, dist::Union{Distribution,Function}, is_observed::Bool |
function marginal_distribution(bn::BayesianNetwork{V}, query_var::V) where {V} | ||
# Get query variable id | ||
query_id = bn.names_to_ids[query_var] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
# Get topological ordering | ||
ordered_vertices = Graphs.topological_sort_by_dfs(bn.graph) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
if any(isnothing, parent_values) | ||
return nothing | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ordered_vertices = [1, 2] # Eliminate X1, then X2 | ||
query_id = 3 # Query X3 | ||
result = eliminate_variables(bn, ordered_vertices, query_id, Dict{Symbol,Any}()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
@testset "Marginal Distribution P(X3|X1)" begin | ||
bn = BayesianNetwork{Symbol}() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
# X1 ~ Uniform(0,1) | ||
add_stochastic_vertex!(bn, :X1, Uniform(0, 1), false) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# X2 ~ Bernoulli(X1) | ||
add_stochastic_vertex!(bn, :X2, x1 -> Bernoulli(x1), false) | ||
add_edge!(bn, :X1, :X2) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# X3 ~ Normal(μ(X2), 1) | ||
add_stochastic_vertex!(bn, :X3, x2 -> Normal(x2 == 1 ? 10.0 : 2.0, 1.0), false) | ||
add_edge!(bn, :X2, :X3) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
No description provided.