# Segment Analysis

An evaluation's mean score tells you how your agent did overall. Segment analysis shows where it did well and where it struggled. It slices the scored test cases by the benchmark's **dimensions**, such as persona, question phrasing or response length. A **segment** is the set of cases that have one value of a dimension (for example Persona: Young Adult), or one value of each of two dimensions.

The **Segments** tab shows one metric by one dimension, or by two dimensions crossed. Selecting a cell opens the cases behind it.

## Where the dimensions come from

Dimensions come from the categories stored with each evaluated case:

- A Documents benchmark generated [by specification](specifications.md) can have both categories declared in its specification and additional categories discovered by MorganaBench.
- A [More Like This](more-like-this.md#categories-in-evaluation-results) benchmark is generated from seed examples rather than declared categories and can have discovered categories.
- A Tools benchmark uses its declared categories; automatic category discovery does not run for tools.

Discovered categories are marked **Inferred** in the Segments tab. Hovering a dimension or value shows its description, when available. Both declared and discovered categories can be used in Segments, Issues, and the Case details filters. The benchmark page shows only declared categories, and the category list for an individual turn does not show the conversation-level discovered labels.

MorganaBench discovers categories from the generated cases and expected responses, without using the agent's responses or scores. Importing external examples for evaluation currently does not start category discovery.

The category assignments are stored in `inputs.metadata`:

- A category set on the conversation (`inputs.metadata.categories`) is used as is.
- A discovered category (`inputs.metadata.inferred_categories`) is used like a conversation-level category.
- Categories on the final turn (`inputs.metadata.turns[-1].categories`) are combined with conversation-level categories. The final turn's value wins if both define the same category; earlier turns are not used.
- A case with no value for a dimension counts as **Unspecified**, the same segment as cases labelled Unspecified, listed last. It is scored like any other segment, so it can also appear in [Issues](issues.md). A case has no value when none of the dimension's labels fits it, for example a final turn whose request matches none of them. Segment counts always add up to the number of cases.

## The table

![Segments tab with one dimension](/docs/assets/figures/evaluation-segments-by-segment.png)

- **Metric** selects the metric the table shows.
- **Rows** selects the dimension used for the rows.
- **Columns** is `None` by default. Select a second dimension to cross it with the rows.

![Segments tab with both dimensions crossed](/docs/assets/figures/evaluation-segments-across-segments.png)

A dimension can't be used for both rows and columns. Every segment is shown, however small: a segment with 2 cases gets a score like any other, marked low confidence rather than hidden. The **All** row and column show the mean over everything in that row or column. The cell where they meet is the evaluation's overall score, which every other cell is compared with.

## Cells

The score is shown in the metric's own units: a percentage for metrics scored from 0 to 1, and the plain value for other scales (for example 3.7 on a 1–5 scale).

Colors follow the bands described in [Reading a score](metrics.md#reading-a-score), so they depend on the metric's range and not on the overall score.

Hovering a cell shows how many of the segment's cases were scored, and how far the score is from the overall score, e.g. "13 pts above the overall score (better)". The difference is in the same units as the score. "(better)" and "(worse)" respect the metric's direction.

![A segment cell's tooltip](/docs/assets/figures/evaluation-segments-cell-tooltip.png)

A **low confidence** icon marks an imprecise score. See [Reading a score](metrics.md#reading-a-score).

## Opening the cases

Selecting a cell opens the **Case details** tab filtered to that segment, with one [filter](../ui-guide/evaluations.md#filtering-cases) per selected dimension. All metrics stay visible.

![Drill-down from a segment cell into the Case details tab](/docs/assets/figures/evaluation-segments-drilldown.png)

## When segments are missing

A benchmark's **Ready** status confirms that the generated examples are available to download and use; category discovery may still be running. An evaluation of it is scored right away, then waits, still **Processing**, until discovery finishes, so its Segments and Issues include the discovered categories. The wait lasts at most 60 minutes after scoring; past it, the evaluation finishes without discovered categories and says so. Benchmark downloads never include discovered labels; an evaluation's results include the ones it used, in `inputs.metadata.inferred_categories`.

A case's categories reach the results in its `inputs`. If your agent output rebuilds `inputs` instead of returning them unchanged, those cases carry no categories and land in **Unspecified**. If none of them arrive, the tab says *Segment categories are missing from these results*. Return each example's `inputs` exactly as you received them, or use the [outputs-only shape](../ui-guide/evaluations.md#two-accepted-shapes), where MorganaBench reads `inputs` back from the benchmark.

*No segment dimensions found* means no categories are available for this evaluation. Discovered categories are not guaranteed for every benchmark; their absence does not prevent you from evaluating it.

## Sharing a view

The tab, table and filters are stored in the URL, so you can share a link to any view.

| Parameter | Value |
|-----------|-------|
| `tab` | `overall`, `detailed` (Case details), `segments` or `issues` |
| `dim` | Rows dimension |
| `dim2` | Columns dimension. Absent when Columns is `None`. |
| `smetric` | Metric shown in the table |
| `seg` | Segment filter as `<dimension>:<value>`. Repeat for several values. |

```
?tab=segments&dim=persona&dim2=politeness&smetric=faithfulness
?tab=detailed&seg=persona:teenager
```

Values are percent-encoded. Copy the link from the address bar instead of writing it by hand. A dimension or metric that doesn't exist in an evaluation falls back to the first available one. Unknown parameters are ignored.

## See also

- [Evaluation](evaluation.md)
- [Metrics](metrics.md)
- [Issues](issues.md)
- [Evaluations UI guide](../ui-guide/evaluations.md)