<!--
{
  "availability" : [
    "macOS: 13.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLRecommender/evaluation(on:userColumn:itemColumn:ratingColumn:cutoffs:excludingObserved:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Create ML"
    ],
    "preciseIdentifier" : "s:8CreateML13MLRecommenderV10evaluation2on10userColumn04itemG006ratingG07cutoffs17excludingObservedAA0C7MetricsV11TabularData0O5FrameV_S3SSgSaySiGSbtF::OverloadGroup"
  },
  "title" : "evaluation(on:userColumn:itemColumn:ratingColumn:cutoffs:excludingObserved:)"
}
-->

# evaluation(on:userColumn:itemColumn:ratingColumn:cutoffs:excludingObserved:)

Computes the metrics for the given testing data.

```
func evaluation(on testingData: DataFrame, userColumn: String, itemColumn: String, ratingColumn: String? = nil, cutoffs: [Int] = [1, 2, 3, 4, 5], excludingObserved: Bool = true) -> MLRecommenderMetrics
```

## Parameters

`testingData`

A MLDataTable containing testing data.

`userColumn`

Name of the Int or String typed column in the testing data containing user identifiers.

`itemColumn`

Name of the Int or String typed column in the testing data containing item identifiers.

`ratingColumn`

Name of an Int or Double typed column optionally in the testing data containing
scores or ratings. The default is nil, which corresponds to no rating column.

`cutoffs`

A list of Ints corresponding to each value at which the precision and recall will be evaluated.
The default is [1,2,3,4,5].

`excludingObserved`

Specifies whether user-item interactions observed in the training data are excluded when
generating evaluation result. The default is true.

## Discussion

Let P𝑘 be a vector of the first k items recommended by the model for a particular user and
let A be the set of items in the provided testingData for the same user.

The “precision at cutoff k” for this user is:
precision(k) = |A ∩ P𝑘| / k

while “recall at cutoff k” for this user is:
recall(k) = |A ∩ P𝑘| / |A|

where |A ∩ P𝑘| is the number of elements in the intersection of A and P𝑘 and |A| is the
number of elements in A.

---

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)