class documentation
class FacetAggregations(Aggregation): (source)
Constructor: FacetAggregations(field_name, aggregations, _compiled)
Efficiently computes a set of aggregations rooted at a common path using faceted computations.
Note
All aggregations provided to this method are interpreted relative to the provided field_name.
Examples:
import fiftyone as fo dataset = fo.Dataset() dataset.add_samples( [ fo.Sample( filepath="/path/to/image1.png", tags=["sunny"], predictions=fo.Detections( detections=[ fo.Detection(label="cat", confidence=0.4), fo.Detection(label="dog", confidence=0.5), ] ), ), fo.Sample( filepath="/path/to/image2.png", tags=["sunny", "cloudy"], predictions=fo.Detections( detections=[ fo.Detection(label="cat", confidence=0.6), fo.Detection(label="rabbit", confidence=0.7), ] ), ), fo.Sample( filepath="/path/to/image3.png", predictions=None, ), ] ) # # Compute prediction label value counts and confidence bounds # values, bounds = dataset.aggregate( fo.FacetAggregations( "predictions.detections", [fo.CountValues("label"), fo.Bounds("confidence")] ) ) print(values) # label value counts print(bounds) # confidence bounds
Parameters | |
field | a field name or embedded.field.name |
aggregations | a list or dict of Aggregation instances |
Method | __init__ |
Undocumented |
Method | default |
Returns the default result for this aggregation. |
Method | parse |
Parses the output of to_mongo . |
Method | to |
Returns the MongoDB aggregation pipeline for this aggregation. |
Static Method | _get |
Undocumented |
Static Method | _parse |
Undocumented |
Static Method | _serialize |
Undocumented |
Method | _kwargs |
Returns a list of [name, value] lists describing the parameters of this aggregation instance. |
Method | _serialize |
Returns a JSON dict representation of the Aggregation . |
Instance Variable | _aggregations |
Undocumented |
Instance Variable | _compiled |
Undocumented |
Instance Variable | _is |
Undocumented |
Instance Variable | _path |
Undocumented |
Instance Variable | _raw |
Undocumented |
Instance Variable | _uuid |
Undocumented |
Inherited from Aggregation
:
Method | __eq__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __str__ |
Undocumented |
Property | expr |
The expression being computed, if any. |
Property | field |
The name of the field being computed on, if any. |
Property | safe |
Whether nan/inf values will be ignored when dealing with floating point values. |
Class Method | _from |
Creates an Aggregation instance from a serialized JSON dict representation of it. |
Method | _needs |
Whether the aggregation requires frame labels of video samples to be attached. |
Method | _needs |
Whether the aggregation requires group slice(s) to be attached. |
Instance Variable | _expr |
Undocumented |
Instance Variable | _field |
Undocumented |
Instance Variable | _safe |
Undocumented |
Property | _has |
Whether the aggregation's result is returned across multiple documents. |
Property | _is |
Whether the aggregation has big results and its pipeline is defined by a single $project stage and thus can be combined with other such aggregations. |
Returns the default result for this aggregation.
Returns | |
the default result of each sub-aggregation in the same container type as the sub-aggregations were provided (list or dict) |
Parses the output of to_mongo
.
Parameters | |
d | the result dict |
Returns | |
the parsed result of each sub-aggregation in the same container type as the sub-aggregations were provided (list or dict) |
Returns the MongoDB aggregation pipeline for this aggregation.
Parameters | |
sample | the
fiftyone.core.collections.SampleCollection to which
the aggregation is being applied |
context:None | a path context from which to resolve |
Returns | |
a MongoDB aggregation pipeline (list of dicts) |
Returns a list of [name, value] lists describing the parameters of this aggregation instance.
Returns | |
a list of [name, value] lists |
Returns a JSON dict representation of the Aggregation
.
Parameters | |
includeTrue | whether to include the aggregation's UUID in the JSON representation |
Returns | |
a JSON dict |