class documentation

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_namea field name or embedded.field.name
aggregationsa list or dict of Aggregation instances
Method __init__ Undocumented
Method default_result Returns the default result for this aggregation.
Method parse_result Parses the output of to_mongo.
Method to_mongo Returns the MongoDB aggregation pipeline for this aggregation.
Static Method _get_key Undocumented
Static Method _parse_aggregations Undocumented
Static Method _serialize_aggregations 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_dict Undocumented
Instance Variable _path Undocumented
Instance Variable _raw_aggregations 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_name 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_dict Creates an Aggregation instance from a serialized JSON dict representation of it.
Method _needs_frames Whether the aggregation requires frame labels of video samples to be attached.
Method _needs_group_slices Whether the aggregation requires group slice(s) to be attached.
Instance Variable _expr Undocumented
Instance Variable _field_name Undocumented
Instance Variable _safe Undocumented
Property _has_big_result Whether the aggregation's result is returned across multiple documents.
Property _is_big_batchable 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.
def __init__(self, field_name, aggregations, _compiled=False): (source)
def default_result(self): (source)

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)
def parse_result(self, d): (source)

Parses the output of to_mongo.

Parameters
dthe result dict
Returns
the parsed result of each sub-aggregation in the same container type as the sub-aggregations were provided (list or dict)
def to_mongo(self, sample_collection, context=None): (source)

Returns the MongoDB aggregation pipeline for this aggregation.

Parameters
sample_collectionthe fiftyone.core.collections.SampleCollection to which the aggregation is being applied
context:Nonea path context from which to resolve
Returns
a MongoDB aggregation pipeline (list of dicts)
@staticmethod
def _get_key(key, agg): (source)

Undocumented

@staticmethod
def _parse_aggregations(field_name, aggregations): (source)

Undocumented

@staticmethod
def _serialize_aggregations(aggregations, include_uuid=True): (source)

Undocumented

def _kwargs(self, include_uuid=True): (source)

Returns a list of [name, value] lists describing the parameters of this aggregation instance.

Returns
a list of [name, value] lists
def _serialize(self, include_uuid=True): (source)

Returns a JSON dict representation of the Aggregation.

Parameters
include_uuid:Truewhether to include the aggregation's UUID in the JSON representation
Returns
a JSON dict
_aggregations = (source)

Undocumented

_compiled = (source)

Undocumented

_is_dict = (source)

Undocumented

Undocumented

_raw_aggregations = (source)

Undocumented