|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.filter.TrainableFilter
public abstract class TrainableFilter
An abstract filter that uses a
trainable classifier
for training. Subclasses must implement the buildFeatures(Element)
method to convert elements into feature vectors suitable for the classifier.
Instances of this class are not thread-safe and must be synchronized externally, if required.
Field Summary | |
---|---|
static SortedSet<String> |
BOOLEAN_CLASSES
An immutable set of the target classes for the classifier: the strings "false" and "true", in alphabetic order. |
Constructor Summary | |
---|---|
TrainableFilter(TiesConfiguration conf,
NodeFilter positiveFilter,
NodeFilter negativeFilter,
Reranker rerank)
Creates a new instance. |
Method Summary | |
---|---|
boolean |
avoids(Element element)
Whether the filter would avoid to filter an element, if possible. |
abstract FeatureVector |
buildFeatures(Element element)
Converts an element into a feature vector to be used by the trainable classifier. |
void |
init(Document document)
Resets the filter to start processing a new document. |
boolean |
matches(Element element)
Decides whether an element is accepted by this filter. |
boolean |
prefers(Element element)
Whether the filter would prefer to filter an element. |
String |
toString()
Returns a string representation of this object. |
PredictionDistribution |
trainIfNecessary(Element element,
boolean decision)
Trains the correct decision for an element by calling the TrainableClassifier.trainOnError(FeatureVector, String,
java.util.Set) method on the stored trainable classifier. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final SortedSet<String> BOOLEAN_CLASSES
Constructor Detail |
---|
public TrainableFilter(TiesConfiguration conf, NodeFilter positiveFilter, NodeFilter negativeFilter, Reranker rerank) throws ProcessingException
conf
- used to initialize the trainable classifier by calling
TrainableClassifier.createClassifier(java.util.Set,
TiesConfiguration)
positiveFilter
- this filter is queried to decide whether this class
prefers
an elementnegativeFilter
- this filter is queried to decide whether this class
avoids
an elementrerank
- an optional reranker that recalculates probabilities to
introduce a bias (can be used to favor recall over precision, by setting
a bias > 1 for the "true" class, etc.); might be null
ProcessingException
- if the initialization of the trainable
classifier failsMethod Detail |
---|
public abstract FeatureVector buildFeatures(Element element)
element
- the element to convert
public void init(Document document)
ElementFilter.matches(Element)
or ElementFilter.prefers(Element)
on elements of
this document.
init
in interface ElementFilter
document
- the document to processpublic boolean avoids(Element element)
avoids
in interface ElementFilter
element
- the element to consider
true
if this would prefer to avoid filtering the
element; false
otherwisepublic boolean matches(Element element) throws ProcessingException
matches
in interface ElementFilter
element
- the element to test
true
if this filter accepts the element;
false
otherwise
ProcessingException
- if an error occurs during filteringpublic boolean prefers(Element element)
prefers
in interface ElementFilter
element
- the element to consider
true
if this would prefer to filter the element;
false
otherwisepublic String toString()
toString
in class Object
public PredictionDistribution trainIfNecessary(Element element, boolean decision) throws ProcessingException
TrainableClassifier.trainOnError(FeatureVector, String,
java.util.Set)
method on the stored trainable classifier. By using this
method, the classifier will train itself only when necessary.
element
- the element to traindecision
- the correct decision for the element -- whether or not it
should be accepted
TrainableClassifier.trainOnError(FeatureVector, String, java.util.Set)
ProcessingException
- if an error occurs during training
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |