hbayes-0.5.2: Bayesian Networks

Bayes.Examples.Influence

Description

Examples of influence diagrams

An influence diagram is an extension of a Bayesian network with can be used to solve some decision problems. In an influence diagram, there are two new kind of nodes : decision nodes and utility nodes.

Solving an influence diagram means determining the strategies for each decision variable that will maximize the average utility.

There must be an ordering of the decision variables : a path through all the decisions.

A decision variable can depend on other past decisions and probabilistic nodes. In the later case, the variable of the probabilistic node is assumed to be observed before the decision is taken. So, the decision is only trying to maximize the average utility based on what has not been observed (the future and some past probabilistic variables).

A probabilistic node can depend on other probabilistic nodes (like in a Bayesian network) and decision nodes.

An utility is a leaf of the graph.

Example graph

Building an influence diagram is done like for a Bayesian network : by using the right monad.

import Bayes.InfluenceDiagram
studentSimple = snd . runID \$ do

Then, you create the different nodes of the graph:

e <- decisionNode "E" (t :: E)
uc <- utilityNode "UC"
ub <- utilityNode "UB"
i <- chance I (t :: I)
pr <- chance P (t :: Bool)

The types used above are:

data E = Dont | Do deriving(Eq,Enum,Bounded)
data I = Low | Average | High deriving(Eq,Enum,Bounded)

Then, you need to define the dependencies and the numerical values. For probabilistic nodes, it is done like for Bayesian network:

cpt pr [d e] ~~ [1-0.0000001,1 - 0.001,0.0000001, 0.001]
cpt i [p pr, d e] ~~ [0.2,0.1,0.01,0.01,0.6,0.5,0.04,0.04,0.2,0.4,0.95,0.95]

The list may contain decision variables of type DEV and probabilistic variables of type DV or TDV. So, the functions p an d are used for the embedding in the heterogenous list.

For decision nodes, the method is similar but with two differences : The first decision may depend on nothing (just on the assumed future). And there are no values to define for a decision variable since the goal of the influence diagram is to compute them.

decision e noDependencies

For the utility nodes, it is similar to probabilistic nodes. You define the dependencies and the numerical values:

utility uc [e] ~~ [0,-50000]
utility ub [i] ~~ [100000,200000,500000]

Once the influence diagram is defined, you can solve it:

solveInfluenceDiagram studentSimple

The result of this function is the solution : the decision strategies. You may want to display also the original graph to see to which node are corresponding the vertex numbers.

Policy Network

You can transform a solved influence diagram into a policy network : a Bayesian network where decision variables have been replaced with probabilistic variables where the conditional probability table is containing 1 for a choice of variables corresponding to the decision and 0 otherwise.

let l = solveInfluenceDiagram student
g = policyNetwork l student
print g
printGraphValues g

Synopsis

Influence diagrams

Very simple example with one decision node

Student network as found in the book by Barber

Student network as found in the book by Barber

Market diagram

Tests for the networks

theTest :: IO () Source

Solve the influences diagrams for the both student network. Also displays each network

Solve the influence diagram student and convert it into a policy network

Solve the market influence diagram