---
title: "randomSplit(by:seed:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/sequence/randomsplit(by:seed:)-3a1xo"
---

# randomSplit(by:seed:)

Generates two AnnotatedFeatures by randomly splitting the elements of the sequence, at the same proportion within each unique Annotation.

## Declaration

```swift
func randomSplit<Feature, Annotation>(by proportion: Double, seed: Int? = nil) -> ([AnnotatedFeature<Feature, Annotation>], [AnnotatedFeature<Feature, Annotation>]) where Annotation : Hashable, Self.Element == AnnotatedFeature<Feature, Annotation>
```

## Parameters

- `proportion`: A proportion in the range [0.0, 1.0].
- `seed`: A seed number for a random-number generator.

## Return Value

Return Value A tuple of arrays.
