class documentation
class Quantiles(Aggregation): (source)
Constructor: Quantiles(field_or_expr, quantiles, expr, safe)
Computes the quantile(s) of the field values of a collection.
None-valued fields are ignored.
This aggregation is typically applied to numeric field types (or lists of such types):
Examples:
import fiftyone as fo from fiftyone import ViewField as F dataset = fo.Dataset() dataset.add_samples( [ fo.Sample( filepath="/path/to/image1.png", numeric_field=1.0, numeric_list_field=[1, 2, 3], ), fo.Sample( filepath="/path/to/image2.png", numeric_field=4.0, numeric_list_field=[1, 2], ), fo.Sample( filepath="/path/to/image3.png", numeric_field=None, numeric_list_field=None, ), ] ) # # Compute the quantiles of a numeric field # aggregation = fo.Quantiles("numeric_field", [0.1, 0.5, 0.9]) quantiles = dataset.aggregate(aggregation) print(quantiles) # the quantiles # # Compute the quantiles of a numeric list field # aggregation = fo.Quantiles("numeric_list_field", [0.1, 0.5, 0.9]) quantiles = dataset.aggregate(aggregation) print(quantiles) # the quantiles # # Compute the mean of a transformation of a numeric field # aggregation = fo.Quantiles(2 * (F("numeric_field") + 1), [0.1, 0.5, 0.9]) quantiles = dataset.aggregate(aggregation) print(quantiles) # the quantiles
Parameters | |
field | a field name, embedded.field.name,
fiftyone.core.expressions.ViewExpression , or
MongoDB expression
defining the field or expression to aggregate |
quantiles | the quantile or iterable of quantiles to compute. Each quantile must be a numeric value in [0, 1] |
expr | a fiftyone.core.expressions.ViewExpression or
MongoDB expression
to apply to field_or_expr (which must be a field) before
aggregating |
safe | whether to ignore nan/inf values when dealing with floating point values |
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 | _parse |
Undocumented |
Method | _kwargs |
Returns a list of [name, value] lists describing the parameters of this aggregation instance. |
Instance Variable | _is |
Undocumented |
Instance Variable | _quantiles |
Undocumented |
Instance Variable | _quantiles |
Undocumented |
Inherited from Aggregation
:
Method | __eq__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __str__ |
Undocumented |
Property | field |
The name of the field being computed on, if any. |
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. |
Method | _serialize |
Returns a JSON dict representation of the Aggregation . |
Instance Variable | _expr |
Undocumented |
Instance Variable | _field |
Undocumented |
Instance Variable | _safe |
Undocumented |
Instance Variable | _uuid |
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 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) |