de.fu_berlin.ties.classify.winnow
Class WinnowStore

java.lang.Object
  extended by de.fu_berlin.ties.classify.winnow.WinnowStore
All Implemented Interfaces:
Pruner

public class WinnowStore
extends Object
implements Pruner

Feature store used by Winnow. Controls the number of stored features and implements pruning based on the LRU (least recently used) principle.

Instances of this class are synchronized externally by Winnow.

Version:
$Revision: 1.15 $, $Date: 2004/12/06 17:58:06 $, $Author: siefkes $
Author:
Christian Siefkes

Constructor Summary
WinnowStore(float initialWeight, int featureNum, int candidates, int pruneNum)
          Creates a new instance.
WinnowStore(float initialWeight, TiesConfiguration config, String configSuffix)
          Creates a new instance.
 
Method Summary
 float[] getWeights(Integer featureHash)
          Returns the weights of a feature.
 int maxSize()
          Returns the maximum number of features that can be stored by this instance.
 void putWeights(Integer featureHash, float[] weights)
          Stores new weights for a feature.
 void reset()
          Resets the store, completely deleting the prediction model.
 int size()
          Returns the number of features currently stored by this instance.
 Map.Entry[] sortForPruning(Map.Entry[] candidates)
          Sorts an array of map entries that are candidates for being pruned (deleted). This implementation sorts the candidate by the deviation of their weights from the initial weights, so candidates with lower deviation will be pruned first.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WinnowStore

public WinnowStore(float initialWeight,
                   TiesConfiguration config,
                   String configSuffix)
Creates a new instance.

Parameters:
initialWeight - The initial weight of each feature -- this implementation prunes features whose weights deviate least from this initial weight
config - Used to configure this instance
configSuffix - Optional suffix appended to the configuration keys when configuring this instance; might be null

WinnowStore

public WinnowStore(float initialWeight,
                   int featureNum,
                   int candidates,
                   int pruneNum)
Creates a new instance.

Parameters:
initialWeight - The initial weight of each feature -- this implementation prunes features whose weights deviate least from this initial weight
featureNum - The number of features to store
candidates - The number of candidates to consider for each pruning operation
pruneNum - The number of elements to remove by each pruning operation, must not be larger than candidates
Method Detail

getWeights

public float[] getWeights(Integer featureHash)
Returns the weights of a feature.

Parameters:
featureHash - The hash code integer identifying the feature
Returns:
The weights of this feature

maxSize

public int maxSize()
Returns the maximum number of features that can be stored by this instance.

Returns:
the value of the attribute

putWeights

public void putWeights(Integer featureHash,
                       float[] weights)
Stores new weights for a feature.

Parameters:
featureHash - The hash code integer identifying the feature
weights - The new weights of this feature

reset

public void reset()
Resets the store, completely deleting the prediction model.


size

public int size()
Returns the number of features currently stored by this instance.

Returns:
the value of the attribute

sortForPruning

public Map.Entry[] sortForPruning(Map.Entry[] candidates)
Sorts an array of map entries that are candidates for being pruned (deleted). This implementation sorts the candidate by the deviation of their weights from the initial weights, so candidates with lower deviation will be pruned first. This are candidates that were involved in fewer unbalanced promotions and demotions than the other candidate.

Specified by:
sortForPruning in interface Pruner
Parameters:
candidates - an array of entries to be considered as candidates for pruning
Returns:
a resorted array of the entries, sorted by prunability so the entries that should be preferably pruned come first

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2004 Christian Siefkes. All Rights Reserved.