de.fu_berlin.ties.classify.winnow
Class DefaultWinnowStore

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

public class DefaultWinnowStore
extends WinnowStore

Default WinnowStore implementation.

Version:
$Revision: 1.4 $, $Date: 2006/10/21 16:03:59 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
 
Fields inherited from class de.fu_berlin.ties.classify.winnow.WinnowStore
ATTRIB_HASH, ATTRIB_IGNORE_IRRELEVANT, ATTRIB_INIT_WEIGHTS, ATTRIB_MAX_SIZE, ATTRIB_PRUNE_CANDIDATES, ATTRIB_PRUNE_NUMBER, ATTRIB_WEIGHTS, CONFIG_IGNORE_IRRELEVANT, CONFIG_SHARED_STORE, ELEMENT_FEATURE, ELEMENT_MAIN
 
Constructor Summary
DefaultWinnowStore(Element element)
          Creates a new instance from an XML element, fulfilling the recommandation of the XMLStorable interface.
DefaultWinnowStore(float initialWeight, int featureNum, boolean ignoreIrrelevant, int candidates, int pruneNum)
          Creates a new instance.
DefaultWinnowStore(float initialWeight, TiesConfiguration config, String configSuffix)
          Creates a new instance.
 
Method Summary
 float[] getWeights(Feature feature)
          Returns the weights of a feature.
 void putWeights(Feature feature, float[] weights)
          Stores new weights for a feature.
 void removed(Object key)
          Method to be called whenever a key has been removed from a map.
 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.
protected  AdaptableLRUMap store()
          Allows raw access to the internal store.
 ObjectElement toElement()
          Stores all relevant fields of this object in an XML element for serialization.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class de.fu_berlin.ties.classify.winnow.WinnowStore
create, destroy, initStore, initStore, isIgnoringIrrelevant, isRelevant, maxSize, removeFromRelevantKeys, reset, setRelevant, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultWinnowStore

public DefaultWinnowStore(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

DefaultWinnowStore

public DefaultWinnowStore(float initialWeight,
                          int featureNum,
                          boolean ignoreIrrelevant,
                          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
ignoreIrrelevant - whether features within a certain range around the default weight are ignored during classification
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

DefaultWinnowStore

public DefaultWinnowStore(Element element)
Creates a new instance from an XML element, fulfilling the recommandation of the XMLStorable interface.

Parameters:
element - the XML element containing the serialized representation
Method Detail

getWeights

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

Specified by:
getWeights in class WinnowStore
Parameters:
feature - the feature to look up
Returns:
The weights of this feature

putWeights

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

Specified by:
putWeights in class WinnowStore
Parameters:
feature - the feature to use
weights - The new weights of this feature

removed

public void removed(Object key)
Method to be called whenever a key has been removed from a map.

Parameters:
key - the key that has been removed

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.

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

store

protected AdaptableLRUMap store()
Allows raw access to the internal store. Used by the WinnowStore.maxSize(), WinnowStore.size() and WinnowStore.reset() methods.

Specified by:
store in class WinnowStore
Returns:
the value of the attribute

toElement

public ObjectElement toElement()
Stores all relevant fields of this object in an XML element for serialization. An equivalent object can be created by calling ObjectElement.createObject(org.dom4j.Element, Class) on the created element.

Returns:
the created XML element

toString

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

Overrides:
toString in class Object
Returns:
a textual representation


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