---
title: "LayerPrediction"
description: "Prediction result for a single layer."
canonical_url: "https://www.rosette.dev/docs/api-reference/LayerPrediction"
markdown_url: "https://www.rosette.dev/docs/api-reference/LayerPrediction.md"
source_url: "https://github.com/PreFab-Photonics/rosette/blob/f086d7670645fd36c05362d696d442a2b2e74850/www/content/docs/api-reference/LayerPrediction.mdx"
docs_channel: "main"
docs_revision: "f086d7670645fd36c05362d696d442a2b2e74850"
---

# LayerPrediction

Prediction result for a single layer.

Import with `from rosette.dfm import LayerPrediction`.

Each `LayerPrediction` in a `DfmResult` contains the predicted polygons,
comparison metrics, violations, and optional raster data for one layer.

```python
result = run_dfm(cell, layers=[Layer(1)])
for lp in result.layers:
    print(f"Layer {lp.layer}: {lp.predicted_polygon_count} predicted polygons")
    if lp.metrics:
        print(f"  Area deviation: {lp.metrics.area_deviation:.1%}")
    for v in lp.violations:
        print(f"  Violation: {v.message}")
```

## Attributes



### `layer`

```python
layer: tuple[int, int]
```

The `(number, datatype)` of the layer.





### `predicted_polygons`

```python
predicted_polygons: list[Polygon]
```

List of predicted (post-fabrication) polygons extracted from the contour.





### `input_polygon_count`

```python
input_polygon_count: int
```

Number of input (designed) polygons on this layer.





### `predicted_polygon_count`

```python
predicted_polygon_count: int
```

Number of predicted polygons on this layer.





### `metrics`

```python
metrics: LayerMetrics | None
```

Comparison metrics between designed and predicted geometry. `None` if
metrics computation was skipped.





### `violations`

```python
violations: list[DfmViolation]
```

List of DFM violations detected on this layer.





### `has_raster`

```python
has_raster: bool
```

`True` if raw raster data is available (requires `keep_raster=True` in
`DfmConfig`).





### `raster_data`

```python
raster_data: list[float] | None
```

Raw raster data as a flat list of float values in `[0.0, 1.0]`, row-major
order. `None` if `keep_raster` was `False`.





### `raster_width`

```python
raster_width: int | None
```

Width of the raster in pixels. `None` if `keep_raster` was `False`.





### `raster_height`

```python
raster_height: int | None
```

Height of the raster in pixels. `None` if `keep_raster` was `False`.





### `raster_origin`

```python
raster_origin: tuple[float, float] | None
```

Origin `(x, y)` of the raster in design units. `None` if `keep_raster`
was `False`.