tmpLearn
Class Learner

java.lang.Object
  extended by infer.Infer
      extended by tmpLearn.Learner
Direct Known Subclasses:
BetterDNLearner, NaiveDNLearner, NaiveGDLearner

public abstract class Learner
extends Infer

The abstract class of learning a weight of MLN. A runnable learner should extend this abstract class by specifying some ad-hoc functions. This class extends Infer class, because it uses inference as subroutines. NOTE, THIS CLASS HAS A STATIC VARIABLE CURRENTWEIGHT. PARALLEL RUNNING OF MULTIPLE LEARNER INSTANCEs MAY CAUSE PROBLEMS... NOTE2, CURRENTLY ASSUME THE ACTIVE SET IS NOT CHANGED WHEN FLIPPING A POSITIVE CLAUSE TO NEGATIVE CLAUSE.


Field Summary
 int backtrackCount_
           
 boolean backtracked
           
static java.util.HashMap<java.lang.String,java.lang.Double> currentD
           
static java.util.HashMap<java.lang.String,java.lang.Double> currentWeight
          Map from clause name to current clause weight.
static java.util.HashMap<java.lang.String,java.lang.Double> finalWeight
          Map from clause name to final weight.
 boolean isFirstTime
           
static java.util.HashMap<java.lang.String,java.lang.Boolean> isHardMappings
          Map from clause name to whether it is assigned to hard weight clause while learning.
 double odds
          FOR JUNIT TEST ONLY.
 java.util.HashMap<java.lang.String,java.lang.Double> oldWeight
          Map from clause name to clause weight learned in last iteration.
 java.util.HashMap<java.lang.String,java.lang.Integer> trainingSatisification
          Map from clause name to current training data satisfication.
 java.util.HashMap<java.lang.String,java.lang.Integer> trainingViolation
          Map from clause name to current training data violation.
 
Fields inherited from class infer.Infer
db, grounding, mln, options
 
Constructor Summary
Learner()
           
 
Method Summary
 void dumpAnswers()
          Output the learning result to file CommandOptions.fout.
 void fillInCurrentWeight(MCSAT _mcsat)
          Init.
abstract  void loadingTrainingData(MCSAT _mcsat)
          Reading from training data and fill it into MRF.atoms.
 void run(CommandOptions opt)
          run the learner
abstract  boolean updateWeight(MCSAT mcsat)
          Update currentWeight to new weights according to information provided by mcsat instance, e.g., MCSAT.expectationOfViolation; This is a virtual function, each instance of Learner should materialize an adhoc version of this function.
 double validatingLearningPerformance(MCSAT mcsat, MCSAT _mcsat)
          DEBUG ONLY!.
 
Methods inherited from class infer.Infer
cleanUp, ground, loadMLN, setUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

backtrackCount_

public int backtrackCount_

backtracked

public boolean backtracked

currentD

public static java.util.HashMap<java.lang.String,java.lang.Double> currentD

currentWeight

public static java.util.HashMap<java.lang.String,java.lang.Double> currentWeight
Map from clause name to current clause weight.


finalWeight

public static java.util.HashMap<java.lang.String,java.lang.Double> finalWeight
Map from clause name to final weight. Here by final weight, it means the the average of the weight in each iteration.


isFirstTime

public boolean isFirstTime

isHardMappings

public static java.util.HashMap<java.lang.String,java.lang.Boolean> isHardMappings
Map from clause name to whether it is assigned to hard weight clause while learning.


odds

public double odds
FOR JUNIT TEST ONLY.


oldWeight

public java.util.HashMap<java.lang.String,java.lang.Double> oldWeight
Map from clause name to clause weight learned in last iteration.


trainingSatisification

public java.util.HashMap<java.lang.String,java.lang.Integer> trainingSatisification
Map from clause name to current training data satisfication.


trainingViolation

public java.util.HashMap<java.lang.String,java.lang.Integer> trainingViolation
Map from clause name to current training data violation.

Constructor Detail

Learner

public Learner()
Method Detail

dumpAnswers

public void dumpAnswers()
Output the learning result to file CommandOptions.fout.


fillInCurrentWeight

public void fillInCurrentWeight(MCSAT _mcsat)
Init. weight according to log odd of training data.

Parameters:
_mcsat - MCSAT instance containing the vio/sat informaiton.

loadingTrainingData

public abstract void loadingTrainingData(MCSAT _mcsat)
Reading from training data and fill it into MRF.atoms. This function should be materialized by an instance of abstract class Learner.

Parameters:
_mcsat - The MCSAT object to be filled in.

run

public void run(CommandOptions opt)
         throws java.sql.SQLException
run the learner

Parameters:
opt - Command line Options
Throws:
java.sql.SQLException

updateWeight

public abstract boolean updateWeight(MCSAT mcsat)
Update currentWeight to new weights according to information provided by mcsat instance, e.g., MCSAT.expectationOfViolation; This is a virtual function, each instance of Learner should materialize an adhoc version of this function. This function should return whether it think this iteration should terminate.

Parameters:
mcsat - MCSAT instance after this iteration.
Returns:
Whether terminate.

validatingLearningPerformance

public double validatingLearningPerformance(MCSAT mcsat,
                                            MCSAT _mcsat)
DEBUG ONLY!. This function measures the quality of learning. Instead of using pseudo-likelihood, it uses the overlapping between MAP inference in current weight-settings and training data.

Parameters:
mcsat - MCSAT instance after this iteration.
_mcsat - MCSAT instance saving training data.
Returns:
the performance measure.