|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.classify.winnow.WinnowStore
public abstract class WinnowStore
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.
Field Summary | |
---|---|
protected static QName |
ATTRIB_HASH
Name of the attribute used to store feature hashes for XML serialization. |
protected static QName |
ATTRIB_IGNORE_IRRELEVANT
Attribute name used for XML serialization. |
protected static QName |
ATTRIB_INIT_WEIGHTS
Name of the attribute used to store the initial weight for XML serialization. |
protected static QName |
ATTRIB_MAX_SIZE
Name of the attribute used to store the maximum number of features for XML serialization. |
protected static QName |
ATTRIB_PRUNE_CANDIDATES
Name of the XML attribute used to store number of candidates to consider for pruning. |
protected static QName |
ATTRIB_PRUNE_NUMBER
Name of the XML attribute used to store number of elements to remove by each pruning operation. |
protected static QName |
ATTRIB_WEIGHTS
Name of the attribute used to store feature weight arrays for XML serialization. |
protected static String |
CONFIG_IGNORE_IRRELEVANT
Configuration parameter: whether "irrelevant" keys should be ignored. |
static String |
CONFIG_SHARED_STORE
Configuration parameter: Whether a shared feature store is used for all Winnow instances. |
protected static QName |
ELEMENT_FEATURE
Name of the element used to store features for XML serialization. |
static QName |
ELEMENT_MAIN
Name of the main element used for XML serialization. |
Constructor Summary | |
---|---|
WinnowStore(boolean ignoreIrrelevant)
Creates a new instance. |
|
WinnowStore(TiesConfiguration config,
String configSuffix)
Creates a new instance. |
Method Summary | |
---|---|
static WinnowStore |
create(float initialWeight,
TiesConfiguration config,
String configSuffix)
Factory method that creates and configures a new instance. |
void |
destroy()
Destroys the store if it will never be used again. |
abstract float[] |
getWeights(Feature feature)
Returns the weights of a feature. |
protected AdaptableLRUMap |
initStore(int featureNum,
int candidates,
int pruneNum)
Helper method that initializes the internal store. |
protected AdaptableLRUMap |
initStore(TiesConfiguration config,
String configSuffix)
Helper method that initializes the internal store. |
boolean |
isIgnoringIrrelevant()
Whether features within a certain range around the default weight are ignored during classification. |
boolean |
isRelevant(Feature feature)
Whether a feature is considered relevant for classification. |
int |
maxSize()
Returns the maximum number of features that can be stored by this instance. |
abstract void |
putWeights(Feature feature,
float[] weights)
Stores new weights for a feature. |
protected void |
removeFromRelevantKeys(Long key)
Helper method that removes a key from the set of relevant keys. |
void |
reset()
Resets the store, completely deleting the prediction model. |
void |
setRelevant(Feature feature,
boolean relevant)
Marks a feature as relevant or irrelevant for classification. |
int |
size()
Returns the number of features currently stored by this instance. |
protected abstract AdaptableLRUMap |
store()
Allows raw access to the internal store. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.fu_berlin.ties.util.Pruner |
---|
sortForPruning |
Methods inherited from interface de.fu_berlin.ties.util.RemoveCallback |
---|
removed |
Methods inherited from interface de.fu_berlin.ties.io.XMLStorable |
---|
toElement |
Field Detail |
---|
protected static final String CONFIG_IGNORE_IRRELEVANT
public static final String CONFIG_SHARED_STORE
public static final QName ELEMENT_MAIN
protected static final QName ELEMENT_FEATURE
protected static final QName ATTRIB_HASH
protected static final QName ATTRIB_WEIGHTS
protected static final QName ATTRIB_INIT_WEIGHTS
protected static final QName ATTRIB_IGNORE_IRRELEVANT
protected static final QName ATTRIB_PRUNE_NUMBER
protected static final QName ATTRIB_PRUNE_CANDIDATES
protected static final QName ATTRIB_MAX_SIZE
Constructor Detail |
---|
public WinnowStore(TiesConfiguration config, String configSuffix)
config
- Used to configure this instanceconfigSuffix
- Optional suffix appended to the configuration keys
when configuring this instance; might be null
public WinnowStore(boolean ignoreIrrelevant)
ignoreIrrelevant
- whether features within a certain range around
the default weight are ignored during classificationMethod Detail |
---|
public static WinnowStore create(float initialWeight, TiesConfiguration config, String configSuffix)
initialWeight
- The initial weight of each feature -- this
implementation prunes features whose weights deviate least from this
initial weightconfig
- Used to configure this instanceconfigSuffix
- Optional suffix appended to the configuration keys
when configuring this instance; might be null
protected abstract AdaptableLRUMap store()
maxSize()
,
size()
and reset()
methods.
public void destroy()
reset()
, but subclasses can
overwrite this behaviour if appropriate.
public abstract float[] getWeights(Feature feature)
feature
- the feature to look up
protected AdaptableLRUMap initStore(int featureNum, int candidates, int pruneNum)
featureNum
- The number of features to storecandidates
- The number of candidates to consider for each pruning
operationpruneNum
- The number of elements to remove by each pruning
operation, must not be larger than candidates
protected AdaptableLRUMap initStore(TiesConfiguration config, String configSuffix)
config
- Used to configure this instanceconfigSuffix
- Optional suffix appended to the configuration keys
when configuring this instance; might be null
public boolean isIgnoringIrrelevant()
public boolean isRelevant(Feature feature)
feature
- the feature to look up
public int maxSize()
public abstract void putWeights(Feature feature, float[] weights)
feature
- the feature to useweights
- The new weights of this featureprotected void removeFromRelevantKeys(Long key)
key
- the key to removepublic void reset()
public void setRelevant(Feature feature, boolean relevant)
feature
- the feature to markrelevant
- whether or not the feature is relevantpublic int size()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |