NORSYS SOFTWARE © 2012  NETICA API  JAVA VERSION 5.04 


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object  +norsys.netica.Learner
An object for managing batchmode learning, such as EM or Gradient Descent learning, of CPTs from case data.
Currently only batchmode learning is supported, but it is intended that in future, all modes of learning will be managed by this class.
Field Summary  
static int 
COUNTING_LEARNING
Indicates the case counting learning algorithm. 
static int 
EM_LEARNING
Indicates the EM (Expectation Maximization) learning algorithm. 
static int 
GRADIENT_DESCENT_LEARNING
Indicates the Gradient Descent learning algorithm. 
Constructor Summary  
Learner(int method)
Creates and returns a new Learner object for use in learning of CPTs from case data, and associates it with the default Netica environment. 

Learner(int method,
java.lang.String info,
Environ env)
Creates and returns a new Learner object for use in learning of CPTs from case data, and associates it with a given Netica environment. 
Method Summary  
void 
finalize()
Removes the Learner object and frees all its resources (e.g., memory). 
Environ 
getEnviron()
Returns the Environ that this object belongs to. 
int 
getMaxIterations()
Returns the maximum number of learningstep iterations for learnCPTs. 
double 
getMaxTolerance()
Returns the tolerance for the minimum change in data log likelihood between consecutive passes through the data, as a termination condition for any learning to be done by learner. 
int 
getMethod()
Returns the algorithmic method used by this learner, one of COUNTING_LEARNING, EM_LEARNING, or GRADIENT_DESCENT_LEARNING. 
void 
learnCPTs(NodeList nodeList,
Caseset caseset,
double degree)
Performs learning of CPT tables from data. 
void 
setMaxIterations(int maxIterations)
Sets the maximum number of learningstep iterations (i.e., complete passes through the data) which will be done when learner is used, after which learning will be automatically terminated. 
void 
setMaxTolerance(double logLikelihoodTolerance)
Sets the tolerance for the minimum change in data log likelihood between consecutive passes through the data, as a termination condition for any learning to be done by learner. 
Methods inherited from class java.lang.Object 
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 
public static int COUNTING_LEARNING 
public static int EM_LEARNING 
public static int GRADIENT_DESCENT_LEARNING 
Constructor Detail 
public Learner ( 
 ) throws NeticaException 
After creating this object, you use it to set the learning parameters you want, and then you pass it to a learning method, such as learnCPTs, to actually perform the learning on some net using some data file.
method should be one of COUNTING_LEARNING, EM_LEARNING, or GRADIENT_DESCENT_LEARNING. See learnCPTs for a description of how each learning algorithm operates.
This method is identical to calling new Learner(method,null,Environ.getDefaultEnviron()).
Parameters:
int  method  The type of learning algorithm that this Learner should use: one of COUNTING_LEARNING, EM_LEARNING, or GRADIENT_DESCENT_LEARNING. 
Learner(int,Environ)  Same, but for any environment  
setMaxIterations  Set the maximum number of iterations (if applicable) it will do when learning  
setMaxTolerance  Set the maximum tolerance (if applicable) it will allow before termination  
learnCPTs  Performs the learning  
finalize  Discard the Learner 
public Learner ( 
 ) throws NeticaException 
After creating this object, you use it to set the learning parameters you want, and then you pass it to a learning method, such as learnCPTs, to actually perform the learning on some net using some data file. When done, you discard the Learner with finalize.
Pass null for options; it is only for future expansion.
method must be one of COUNTING_LEARNING, EM_LEARNING, or GRADIENT_DESCENT_LEARNING. See learnCPTs for a description of how each learning algorithm operates.
Parameters:
int  method  The type of learning method that this Learner should use: one of COUNTING_LEARNING, EM_LEARNING, or GRADIENT_DESCENT_LEARNING.  
String  options  For future expandability. Pass null for now.  
Environ  env  The Environ in which this new Learner will be placed. 
setMaxIterations  Set the maximum number of iterations (if applicable) it will do when learning  
setMaxTolerance  Set the maximum tolerance (if applicable) it will allow before termination  
learnCPTs  Performs the learning  
finalize  Discard the Learner  
RandomGenerator  May also want this to control randomization 
See addCases
Method Detail 
public void finalize ( ) throws NeticaException 
Learner  Create a new Learner 
finalize
in class java.lang.Object
public Environ getEnviron ( ) 
public int getMaxIterations ( ) throws NeticaException 
See setMaxIterations for additional documentation.
Version:
Learner  Create a new Learner  
setMaxIterations  Sets it  
getMaxTolerance  Retrieves another termination parameter  
learnCPTs  Performs the learning iterations 
public double getMaxTolerance ( ) throws NeticaException 
See setMaxTolerance for additional documentation.
Version:
setMaxTolerance  Sets it  
getMaxIterations  Retrieves another termination parameter  
learnCPTs  Performs the learning 
public int getMethod ( ) 
public void learnCPTs ( 
 ) throws NeticaException 
nodeList is the list of nodes whose experience and conditional probability tables are to be updated by learning. They must all be from the same net. Other nodes in that net will not be modified.
cases is the set of cases to be used for learning.
degree is the frequency factor to apply to each case in the case set. It must be greater than zero. It gets multiplied by the "NumCases" (multiplicity number) which appears for each case in the file (if the number doesn't appear in the file, it is taken as 1).
When you create the Learner (see Learner), you choose the algorithm you wish, which may be one of:
1. Counting Learning
Net.reviseCPTsByFindings
) ... . It is the preferred learning method to use, if there are no hidden (also known as 'latent') nodes in the net and no missing values in the case data. If there are hidden variables, that is, variables for which you have no observations, but you suspect exist and can be useful for modeling your world, or if there are a substantial number of missing values in the case data, then the iterative learning algorithms may yield better results.
Because this learning method is not iterative, setMaxIterations and setMaxTolerance have no affect on it.
2. EM Learning
3. Gradient Descent Learning
After the Learner is created, you can set the termination conditions for it. For both EM learning and gradient descent learning, the two possible termination conditions are the maximum number of iterations of the whole batch of cases (see setMaxIterations), and the minimum change in log likelihood from one pass through the batch to the next (see setMaxTolerance). Termination will occur when either of the two conditions are met. For Counting learning, there currently are no termination conditions to set.
Parameters:
NodeList  nodeList  The list of nodes from the net whose case data will be used for learning the remainder of the net.  
Caseset  caseset  The case set whose cases will be used for learning.  
double  degree  The frequency factor to apply to each case in the case set. 
Learner  Creates the learner  
setMaxIterations  Sets a learning termination parameter: the maximum number of batch iterations  
setMaxTolerance  Sets a learning termination parameter: the minimum log likelihood increase  
Caseset  Creates the Caseset  
reviseCPTsByCaseFile  Uses a different learning algorithm (better suited if there is little missing data)  
deleteTables  May want to do this before learning 
See addCases
public void setMaxIterations ( 
 ) throws NeticaException 
Learning may be terminated earlier, if it first reaches another limit, such as learner's maximum tolerance limit (see setMaxTolerance).
maxIterations must be greater than 0. The default is 1000.
Parameters:
int  maxIterations  The maximum number of learningstep iterations that learnCPTs is allowed to perform. 
Learner  Creates the Learner  
setMaxTolerance  Sets another termination parameter  
getMaxIterations  Retrieves value  
learnCPTs  Performs the learning using this parameter 
public void setMaxTolerance ( 
 ) throws NeticaException 
When learning is performed, with each iteration (i.e., pass through the complete data set), the "log likelihood" of the data given the net is computed. The log likelihood is the percase average of the negative of the logarithm of the probability of the case given the current Bayes net (structure + CPTs). When the difference between the computed loglikelihoods for two consecutive passes falls below this tolerance, the algorithm is halted. So, the closer this tolerance is to zero, the longer the algorithm may take.
The algorithm may terminate earlier if another termination condition is met, such as the maximum number of iterations (see setMaxIterations).
logLikelihoodTolerance must be greater than 0.0. The default is 1.0e5.
Parameters:
double  logLikelihoodTolerance  The value to make this tolerance. 
setMaxIterations  Sets another termination parameter  
getMaxTolerance  Retrieves value  
learnCPTs  Performs the learning using this parameter 


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 