---
title: "prediction(from:maxCount:maxDistance:distanceType:)"
framework: createml
role: symbol
role_heading: Instance Method
path: "createml/mlwordembedding/prediction(from:maxcount:maxdistance:distancetype:)"
---

# prediction(from:maxCount:maxDistance:distanceType:)

Predicts neighbors.

## Declaration

```swift
func prediction(from text: String, maxCount: Int = 10, maxDistance: Double = 2.0, distanceType: NLDistanceType = .cosine) throws -> [(text: String, distance: Double)]
```

## Parameters

- `text`: A string in the embedding vocabulary.
- `maxCount`: The largest number of neighboring strings.
- `maxDistance`: The maximum allowed neighbor distance.
- `distanceType`: The type of distance formula to use for evaluating a neighbor’s distance from the input string.

## Return Value

Return Value An array of neighboring strings and their distances to the input string.

## Discussion

Discussion The distance values are calculated with a formula determined by NLDistanceType, such as NLDistanceType.cosine.

## See Also

### Testing a word embedding

- [distance(between:and:distanceType:)](createml/mlwordembedding/distance(between:and:distancetype:).md)
- [NLDistanceType](naturallanguage/nldistancetype.md)
- [contains(_:)](createml/mlwordembedding/contains(_:).md)
- [vector(for:)](createml/mlwordembedding/vector(for:).md)
