---
title: NLDistanceType.cosine
framework: naturallanguage
role: symbol
role_heading: Case
path: naturallanguage/nldistancetype/cosine
---

# NLDistanceType.cosine

A method of calculating distance by using cosine similarity.

## Declaration

```swift
case cosine
```

## Discussion

Discussion The range of a cosine distance is [0.0, 2.0], derived from the expression 1 - cosine similarity.
