---
title: "randomSample(by:seed:)"
framework: createml
role: symbol
role_heading: Instance Method
path: "createml/mldatatable/randomsample(by:seed:)"
---

# randomSample(by:seed:)

Creates a subset of the table by randomly selecting the given proportion of rows.

## Declaration

```swift
func randomSample(by proportion: Double, seed: Int = 42) -> MLDataTable
```

## Parameters

- `proportion`: The fraction of rows to sample from the original table. The value must be in the range (0.0, 1.0).
- `seed`: A number that seeds a random number generator.

## Return Value

Return Value A new data table.

## See Also

### Discarding rows

- [dropMissing()](createml/mldatatable/dropmissing().md)
- [dropDuplicates()](createml/mldatatable/dropduplicates().md)
- [exclude(_:of:)](createml/mldatatable/exclude(_:of:).md)
