-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hmmh, actually the implementation of the K2 function is a bit weird. Besides the data it takes a dictionary as input. In the supplied example the dictionary already contains the tree ! Thus, if in the for-loop of the K2 function for each node only the supplied parents of the node (tree_xi) are taken as input for the further computation, only the supplied tree can be reproduced.
The original paper of Cooper & Herskovitz says:
"Input: A set of n nodes, an ordering on the nodes, an upper bound u on the number of parents a node may have, and a database D containing m cases."
Thus, instead of a dictionary containing the ordering, an ordered set resp. a list needs to be used in order to avoid to inform the algorithm about the structure of the tree. Of course, then the upper bound on the number of parents needs to be supplied to.