-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.hs
36 lines (31 loc) · 1.14 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Bayes.FactorElimination
import Data.Maybe(fromJust)
import qualified Data.Map as Map
import Bayes
import Bayes.Factor
import Bayes.ImportExport.HuginNet
import System.Directory(getHomeDirectory)
import System.FilePath((</>))
import Bayes.Examples.Tutorial
import qualified Data.Set as Set
genericExample :: String -> IO (Map.Map String DV,SBN CPT)
genericExample s = do
r <- importBayesianGraph s
return (runBN $ fromJust r)
exampleDiabete = do
h <- getHomeDirectory
genericExample $ h </> "Dropbox/bayes_examples/Diabetes.hugin"
testa = do
(varmap,g) <- exampleDiabete
let theMoralGraph = moralGraph g
cmp = nodeComparisonForTriangulation
(clusters,_) = triangulate (cmp theMoralGraph) theMoralGraph
g'' = createClusterGraph clusters :: UndirectedSG Int VertexCluster
t = minimumSpanningTree g''
factorSet = Set.fromList (allVertices g) -- Tracking of factors which have not yet been put in the junction tree
-- A vertex is linked with a factor so vertex is used as the identifier
(newTree, _) = setFactors g t factorSet
print $ newTree
main = do
miscDiabete
--inferencesOnStandardNetwork