Advertisement
Guest User

Untitled

a guest
Jun 8th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1.   def predict(allevidence: Seq[Tuple2[Int,Int]], targetId : Int) : Array[Double] = {    
  2.     //want to create a new generic cluster graph with the same factors as this cluster graph
  3.     val tempCG = ClusterGraph()
  4.     clusterGraph.getClusters.foreach(cluster => tempCG.addCluster(cluster.id, cluster.getFactor))
  5.    
  6.     //set evidence on the new loopyBP
  7.     val loopyBP = LoopyBP(tempCG)
  8.     allevidence.foreach(evidence => if(evidence._2 != -1) loopyBP.setEvidence(evidence))
  9.     loopyBP.marginal(targetId).getValues
  10.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement