<!--
{
  "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/Metric",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Evaluations"
    ],
    "preciseIdentifier" : "s:11Evaluations6MetricV"
  },
  "title" : "Metric"
}
-->

# Metric

A named metric that carries a result value.

```
struct Metric
```

## Overview

Use `Metric` to define a named measurement. The factory methods (`passing`, `failing`,
`scoring`, `ignore`) return a new `Metric` with the result stored inside.

Here’s how you create a custom metric:

```swift
let metric = Metric("Accuracy")
let result = metric.passing(rationale: "Exact match")
```

## Topics

### Creating a metric

[`init(_:)`](/documentation/Evaluations/Metric/init(_:))

Creates a metric with just a name.

### Producing results

[`passing(rationale:)`](/documentation/Evaluations/Metric/passing(rationale:))

Returns a metric with a passing result.

[`failing(rationale:)`](/documentation/Evaluations/Metric/failing(rationale:))

Returns a metric with a failing result.

[`scoring(_:rationale:)`](/documentation/Evaluations/Metric/scoring(_:rationale:))

Returns a metric with a numeric result.

[`ignore(rationale:)`](/documentation/Evaluations/Metric/ignore(rationale:))

Returns a metric with an ignored result, excluded from aggregation.

### Inspecting a result

[`name`](/documentation/Evaluations/Metric/name)

The name of the metric, used as the DataFrame column name.

[`value`](/documentation/Evaluations/Metric/value-swift.property)

The result value of this metric.

[`doubleValue`](/documentation/Evaluations/Metric/doubleValue)

The numeric value of this metric.

[`rationale`](/documentation/Evaluations/Metric/rationale)

An optional rationale describing the result.

[`Value`](/documentation/Evaluations/Metric/Value-swift.enum)

A metric result value.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Copyable`](/documentation/Swift/Copyable)

[`Escapable`](/documentation/Swift/Escapable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

---

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)