k2
Class K2

java.lang.Object
  |
  +--k2.K2

public class K2
extends java.lang.Object

K2 algorithm------learning Bayes Networks from data Based on : Cooper, G F, Herskovits, E (1992). "A Bayesian Method for the Induction of %Probabilistic Networks from Data" Machine Learning Vol. 9 pp. 309-347 Input: An input datafile which contains <1> a set of n nodes <2> an ordering on the nodes <3> an upper bound u on the number of parents a node may have <4> a database D contains m cases Output: Learn the parent nodes for each nodes and return an XMLBIF file representing the learned Bayesian Network Copyright: Copyright (c) 2001 Company: KSU / KDD


Constructor Summary
K2(K2Manager manager, java.util.Vector order)
          K2 constructor - responsible for building the new network shell with the given order and setting up K2 to run.
 
Method Summary
static java.util.Vector extractOrder(BBN network, java.lang.String[] args, int offset)
          loads an ordering from the command console (or an array of strings)
 int[][] getData()
          returns the raw data array.
 BBN getNetwork()
          getNetwork returns K2's version of the network.
 BBN learnNetwork()
          learnNetwork is the main driver for K2.
static void main(java.lang.String[] args)
          A console utility that runs K2 on the specified network and returns the learned network to the specified output file, given the specieid order.
 void reOrderNodes()
          reOrderNodes will put the nodes back in the original order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

K2

public K2(K2Manager manager,
          java.util.Vector order)
K2 constructor - responsible for building the new network shell with the given order and setting up K2 to run.
Parameters:
manager - - the network manager that will contain the training examples and other importnant information.
order - - a vector of Integer objects that specifies which order to set the nodes up.
Method Detail

getNetwork

public BBN getNetwork()
getNetwork returns K2's version of the network. Note - use learnNetwork() before using this method, or else the nodes will have no parents and no probabilities in the CPT table.
Returns:
BBN - the network

main

public static void main(java.lang.String[] args)
A console utility that runs K2 on the specified network and returns the learned network to the specified output file, given the specieid order.

learnNetwork

public BBN learnNetwork()
learnNetwork is the main driver for K2.

getData

public int[][] getData()
returns the raw data array.

reOrderNodes

public void reOrderNodes()
reOrderNodes will put the nodes back in the original order. Call this only after the network has been learned and only if you really need to. The order really shouldn't matter in the end, but someone's module is malfunctioning if the nodes aren't in the expected order. Calling this function more than once will really mess up the order, so be careful about when and where you call this function.

extractOrder

public static java.util.Vector extractOrder(BBN network,
                                            java.lang.String[] args,
                                            int offset)
loads an ordering from the command console (or an array of strings)
Parameters:
network - - the network to check size
args - - the args to load from
offset - - where the ordering starts at in the array
Returns:
Vector - null if failed, otherwise the Vector of Integers.