labelAggregator
labelAggregator:* components aggregate labels
collected from multiple individual documents into a single list of
labels. This can be used for presentation purposes to display a list of dominant labels present in the set of
documents.
You can use the following label aggregators in your analysis requests:
-
labelAggregator:topWeight -
Returns the top-N highest-weighted labels.
labelAggregator:topWeight
Aggregates labels returned by the
labelCollector
for each input document using the
outputWeightFormula.
{
"type": "labelAggregator:topWeight",
"labelCollector": {
"type": "labelCollector:topFromFeatureFields",
"failIfEmbeddingsNotAvailable": true,
"fields": {
"type": "featureFields:reference",
"auto": true
},
"labelFilter": {
"type": "labelFilter:reference",
"auto": true
},
"labelListFilter": {
"type": "labelListFilter:truncatedPhrases"
},
"labelWeighting": "EMBEDDING",
"minTf": 0,
"minWeight": 0,
"minWeightMass": 1,
"tieResolution": "AUTO"
},
"maxLabelsPerDocument": 10,
"maxRelativeDf": 1,
"minAbsoluteDf": 1,
"minRelativeDf": 0,
"minWeight": 0,
"outputWeightFormula": "TF",
"threads": "auto",
"tieResolution": "AUTO"
}
For example, this request displays the top-10 labels that are two words or longer in documents matching the
electric field phrase. Note label aggregator component is declared inside the
labels:fromDocuments
stage.
{
"output": {
"stages": [
"labels"
]
},
"stages": {
"documents": {
"type": "documents:byQuery",
"query": {
"type": "query:string",
"query": "\"electric field\""
},
"limit": "unlimited"
},
"labels": {
"type": "labels:fromDocuments",
"maxLabels": {
"type": "labelCount:fixed",
"value": 10
},
"labelAggregator": {
"type": "labelAggregator:topWeight",
"labelCollector": {
"type": "labelCollector:topFromFeatureFields",
"labelFilter": {
"type": "labelFilter:tokenCount",
"minTokens": 2
}
}
}
}
}
}The request above produces the following output:
{
"result" : {
"labels" : {
"labels" : [
{
"label" : "electric field",
"weight" : 3564.0
},
{
"label" : "magnetic field",
"weight" : 902.0
},
{
"label" : "black hole",
"weight" : 149.0
},
{
"label" : "quantum dot",
"weight" : 146.0
},
{
"label" : "domain wall",
"weight" : 133.0
},
{
"label" : "external electric field",
"weight" : 128.0
},
{
"label" : "thin films",
"weight" : 125.0
},
{
"label" : "pair production",
"weight" : 123.0
},
{
"label" : "electromagnetic field",
"weight" : 118.0
},
{
"label" : "ground state",
"weight" : 113.0
}
]
}
}
}labelCollector
Defines the source of labels for each document. You can tune the source field where labels are read from, as well as a set of filters applied to them, prior to any aggregation.
maxLabelsPerDocument
Maximum number of labels taken for the aggregation from each document.
maxRelativeDf
Maximum relative document frequency of each label to be included in aggregation (inclusive). The threshold is computed relative to the size of document set (scope size). For example, a relative df of 0.8 means if more than 80% of documents contain a given label, it will be skipped in the aggregation.
minAbsoluteDf
Minimum absolute document frequency of each label to be included in aggregation (inclusive).
minRelativeDf
Minimum relative document frequency of each label to be included in aggregation (inclusive). The threshold is computed relative to the size of document set (scope size). For example, a relative df of 0.3 means at least 30% of documents must contain a given label for it to be included in the aggregation.
minWeight
Minimum weight of aggregated labels.
outputWeightFormula
The strategy of computing the output weight for each label.
The outputWeightFormula property supports the following values:
TF-
Weight is computed from aggregated term occurrence counts.
DF-
Weight is computed from aggregated document occurrence counts.
threads
The number of threads used for computing label aggregations.
tieResolution
The strategy of computing the number of returned labels when their weights at the tail of the list are equal and the consuming component requests a fixed number of labels.
The tieResolution property supports the following values:
TRUNCATE-
Truncate the output at the limit of labels set by the consumer component.
EXTEND-
Extend the list of labels past the limit to include all labels with the same weight.
REDUCE-
Reduce the list of labels so that all labels with non-tied weights are included.
AUTO-
Behaves the same as
REDUCE, unless the returned list of labels would be empty, in which case behaves likeEXTEND.
Consumers of labelAggregator:*
The following stages and components take labelAggregator:* as
input:
| Stage or component | Property |
|---|---|
labels:fromDocuments | labelAggregator |