<!--
{
  "availability" : [
    "Xcode: 27.0.0 -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Evaluations",
  "identifier" : "/documentation/Evaluations/MetricsAggregator",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Evaluations"
    ],
    "preciseIdentifier" : "s:11Evaluations17MetricsAggregatorV"
  },
  "title" : "MetricsAggregator"
}
-->

# MetricsAggregator

A utility for computing aggregate statistics from evaluation metrics.

```
struct MetricsAggregator
```

## Overview

```swift
let accuracy = Metric("Accuracy")

func aggregateMetrics(using aggregator: inout MetricsAggregator) {
    aggregator.computeMean(of: accuracy)
    aggregator.computeMaximum(of: accuracy)
    aggregator.computeStandardDeviation(of: accuracy)
}
```

Use this structure to calculate summary statistics like mean, median, and standard deviation from your evaluation results. The aggregator processes metric data from a DataFrame and produces aggregated results.

## Topics

### Computing standard aggregations

[`computeMean(of:)`](/documentation/Evaluations/MetricsAggregator/computeMean(of:))

Computes the mean of a metric and adds it to the aggregated results.

[`computeMedian(of:)`](/documentation/Evaluations/MetricsAggregator/computeMedian(of:))

Computes the median of a metric and adds it to the aggregated results.

[`computeMode(of:)`](/documentation/Evaluations/MetricsAggregator/computeMode(of:))

Computes the mode of a metric and adds it to the aggregated results.

[`computeMinimum(of:)`](/documentation/Evaluations/MetricsAggregator/computeMinimum(of:))

Computes the minimum value of a metric and adds it to the aggregated results.

[`computeMaximum(of:)`](/documentation/Evaluations/MetricsAggregator/computeMaximum(of:))

Computes the maximum value of a metric and adds it to the aggregated results.

### Computing variability

[`computeStandardDeviation(of:)`](/documentation/Evaluations/MetricsAggregator/computeStandardDeviation(of:))

Computes the standard deviation of a metric and adds it to the aggregated results.

[`computeVariance(of:)`](/documentation/Evaluations/MetricsAggregator/computeVariance(of:))

Computes the variance of a metric and adds it to the aggregated results.

### Computing custom aggregations

[`custom(of:label:_:)`](/documentation/Evaluations/MetricsAggregator/custom(of:label:_:))

Computes a custom aggregation from a single metric’s results.

### Grouping metrics

[`group(_:_:)`](/documentation/Evaluations/MetricsAggregator/group(_:_:))

Creates a group of related metrics.

[`Group`](/documentation/Evaluations/MetricsAggregator/Group)

A grouped collection of related metrics.

### Inspecting aggregate results

[`AggregateMetric`](/documentation/Evaluations/AggregateMetric)

An aggregate statistic computed from a metric’s results across the evaluation dataset.

[`AggregationOperation`](/documentation/Evaluations/AggregationOperation)

The type of aggregation operation used to compute a summary statistic.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)