Skip to content

DiscreteBayesNet - CPD order and named categories #89

@drbenvincent

Description

@drbenvincent

I am starting a project using discrete Bayes Nets and I am hoping to use this package, rather than one of the python packages (eg pomegranate or pgmpy). But I have a few questions...

I managed to get a simple example working (made up numbers), with

bn = DiscreteBayesNet()
push!(bn, DiscreteCPD(:smoke, [0.25,0.75]))
push!(bn, DiscreteCPD(:covid, [0.1,0.9]))
push!(bn, DiscreteCPD(:hospital, [:smoke, :covid], [2,2], 
        [Categorical([0.9,0.1]),
         Categorical([0.2,0.8]),
         Categorical([0.7,0.3]),
         Categorical([0.01,0.99]),
        ]))

Could I request a little more information in the documentation about the way in which this CPD is coded? Eventually I was able to figure it out by asking for the CPD table with table(bn, :hospital)
Screenshot 2020-05-22 at 16 11 02
but I'd definitely say more documentation here would help people out.

Secondly, is there a way to name the levels that each node can take? From the docs I attempted a guess at something like this...

bn = DiscreteBayesNet()
push!(bn, DiscreteCPD(:smoke, NamedCategorical([:yes, :no], [0.25, 0.75])))
push!(bn, DiscreteCPD(:covid, NamedCategorical([:yes, :no], [0.1, 0.9])))
push!(bn, DiscreteCPD(:hospital, [:smoke, :covid], [2,2], 
        [NamedCategorical([:yes, :no], [0.9, 0.1]),
         NamedCategorical([:yes, :no], [0.2, 0.8]),
         NamedCategorical([:yes, :no], [0.7, 0.3]),
         NamedCategorical([:yes, :no], [0.01, 0.99])]))

but no luck. Any pointers or updates to the docs on this would be very much appreciated.
Ben

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions