|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.eval.MultiFMetrics
public class MultiFMetrics
Instances of this class manage multiple
FMetrics
for different types. They also
calculate average statistics over all types.
Instances of this class are not thread-safe and must be synchronized externally, if required.
Field Summary | |
---|---|
static String |
ALL
Reserved type used for the calculated sums and averages over all types: <All> . |
static String |
EXT_METRICS
Extension recommended for files storing metrics. |
static String |
KEY_TYPE
Serialization key for the type. |
Constructor Summary | |
---|---|
MultiFMetrics()
Creates a new instance, without calculating summaries. |
|
MultiFMetrics(boolean calcSummaries)
Creates a new instance. |
Method Summary | |
---|---|
protected FMetrics |
createMetrics()
Helper factory method that creates a new FMetrics instance of the
required type. |
protected FMetrics |
createMetrics(FieldMap fieldMap)
Helper factory method that creates a new FMetrics instance of the
required type from a field map. |
void |
incFalseNeg(String type)
Increases the number of false negatives for the given type by 1. |
void |
incFalsePos(String type)
Increases the number of false positives for the given type by 1. |
void |
incTruePos(String type)
Increases the number of true positives for the given type by 1. |
boolean |
isCalculatingSummaries()
Whether summaries are calculated by this type. |
protected FMetrics |
lookupType(String type)
Looks up and if necessary initializes the metrics for a given type. |
void |
restoreEntries(FieldContainer fContainer)
Restores items stored in a field container and adds them to this instance. |
void |
storeEntries(FieldContainer fContainer)
Adds all relevant Storable items in this object to a field
container for serialization. |
void |
storeEntries(FieldContainer fContainer,
String typeName)
Serialization variant that allows specifying a specific name for the type field. |
String |
toString()
Returns a string representation of this object. |
Set |
types()
Returns the set of all types (Strings) currently stored in this instance. |
void |
update(MultiFMetricsView multiMetrics)
Updates the statistics by adding the contents of the given multi-metrics. |
void |
update(String type,
EvalInput input)
Updates the statistics for a specified type, increasing the stored values as specified. |
void |
update(String type,
long addTruePos,
long addFalseNeg,
long addFalsePos)
Updates the statistics for a specified type, increasing the stored values as specified. |
FMetricsView |
view(String type)
Returns a read-only view of the FMetrics of the specified type. |
FMetricsView |
viewAll()
Returns a read-only view of the FMetrics containing the sums and
averages over all types. |
FMetricsSummary |
viewAllSummary()
Optional operation that shows statistical
summaries of precision, recall, and F1 metrics over all types,
if calculated. |
FMetricsSummary |
viewSummary(String type)
Optional operation that shows statistical
summaries of precision, recall, and F1 metrics of the specified type,
if calculated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ALL
<All>
. This string is reserved and cannot be used to
mark regular types.
public static final String KEY_TYPE
public static final String EXT_METRICS
Constructor Detail |
---|
public MultiFMetrics()
public MultiFMetrics(boolean calcSummaries)
calcSummaries
- whether this type should calculate
summariesMethod Detail |
---|
protected FMetrics createMetrics()
FMetrics
instance of the
required type.
SummaryFMetrics
instance if
isCalculatingSummaries()
; a simple FMetrics
instance
otherwiseprotected FMetrics createMetrics(FieldMap fieldMap) throws IllegalArgumentException
FMetrics
instance of the
required type from a field map.
fieldMap
- field map used to initialize the new instance
SummaryFMetrics
instance if
isCalculatingSummaries()
; a simple FMetrics
instance
otherwise
IllegalArgumentException
- if at least one of the parameters is
negative or missing from the field mappublic void incFalseNeg(String type) throws IllegalArgumentException
type
- the type to update
IllegalArgumentException
- if type
is
null
or empty or equal to the reserved ALL
typepublic void incFalsePos(String type) throws IllegalArgumentException
type
- the type to update
IllegalArgumentException
- if type
is
null
or empty or equal to the reserved ALL
typepublic void incTruePos(String type) throws IllegalArgumentException
type
- the type to update
IllegalArgumentException
- if type
is
null
or empty or equal to the reserved ALL
typepublic boolean isCalculatingSummaries()
protected FMetrics lookupType(String type) throws IllegalArgumentException
null
nor empty nor equal to the reserved ALL
type.
type
- the type to check
IllegalArgumentException
- if type
is
null
or empty or equal to the reserved ALL
typepublic void restoreEntries(FieldContainer fContainer) throws IllegalArgumentException
storeEntries(FieldContainer)
on a object of this type.
Any values already contained in this instance are added to, they are not
replaced. The sums and averages
are recalculated from
the provided values, it is not directly read from the container.
Summary information cannot be restored.
restoreEntries
in interface RestorableContainer
fContainer
- the field container to read
IllegalArgumentException
- if fContainer
contains
a wrong kind of FieldMap
spublic void storeEntries(FieldContainer fContainer)
Storable
items in this object to a field
container for serialization.
storeEntries
in interface StorableContainer
fContainer
- the field container to fillpublic void storeEntries(FieldContainer fContainer, String typeName)
storeEntries(FieldContainer)
, KEY_TYPE
will be used.
fContainer
- the container to serialize totypeName
- key to use for the type fieldpublic String toString()
toString
in class Object
public Set types()
types
in interface MultiFMetricsView
public void update(MultiFMetricsView multiMetrics)
multiMetrics
- the metrics to addpublic void update(String type, EvalInput input) throws IllegalArgumentException
type
- the type to updateinput
- contains the number of true and false positives and
false negatives to add
IllegalArgumentException
- if type
is
null
or empty or equal to the reserved ALL
type or
if at least one of the input values is negativepublic void update(String type, long addTruePos, long addFalseNeg, long addFalsePos) throws IllegalArgumentException
type
- the type to updateaddTruePos
- the number of new true positives to addaddFalseNeg
- the number of new false negatives to addaddFalsePos
- the number of new false positives to add
IllegalArgumentException
- f type
is
null
or empty or equal to the reserved ALL
type or
if at least one of the parameters is negativepublic FMetricsView view(String type)
FMetrics
of the specified type.
This is not a snapshot but will change whenever the underlying counts
are changed.
view
in interface MultiFMetricsView
type
- the type to check
null
if no metrics exist for the given typepublic FMetricsView viewAll()
FMetrics
containing the sums and
averages over all types. This is not a snapshot but will change whenever
the underlying counts are changed.
viewAll
in interface MultiFMetricsView
public FMetricsSummary viewAllSummary() throws UnsupportedOperationException
statistical
summaries of precision, recall, and F1 metrics
over all types,
if calculated. This is not a
snapshot but will change whenever the underlying values are changed.
viewAllSummary
in interface MultiFMetricsView
UnsupportedOperationException
- if
isCalculatingSummaries()
is false
public FMetricsSummary viewSummary(String type) throws UnsupportedOperationException
statistical
summaries of precision, recall, and F1 metrics
of the specified type,
if calculated. This is not a
snapshot but will change whenever the underlying values are changed.
viewSummary
in interface MultiFMetricsView
type
- the type to check
UnsupportedOperationException
- if
isCalculatingSummaries()
is false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |