<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLSoundClassifier/DataSource",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Create ML",
      "CreateML"
    ],
    "preciseIdentifier" : "s:8CreateML17MLSoundClassifierV10DataSourceO"
  },
  "title" : "MLSoundClassifier.DataSource"
}
-->

# MLSoundClassifier.DataSource

A representation of a sound-classifier dataset located in the file system or in a data table.

```
enum DataSource
```

## Overview

Use a data source to represent a dataset for training, validating, or testing a sound classifier.

## Topics

### Creating a data source

[`case labeledDirectories(at: URL)`](/documentation/CreateML/MLSoundClassifier/DataSource/labeledDirectories(at:))

Creates a data source from a folder with subfolders that each contain audio files.

[`case labeledFiles(at: URL)`](/documentation/CreateML/MLSoundClassifier/DataSource/labeledFiles(at:))

Creates a data source from a folder that contains audio files, each named after the sound they represent.

[`case filesByLabel([String : [URL]])`](/documentation/CreateML/MLSoundClassifier/DataSource/filesByLabel(_:))

Creates a data source from a dictionary.

[`case features(table: MLDataTable, featureColumn: String, labelColumn: String, parameters: MLSoundClassifier.FeatureExtractionParameters)`](/documentation/CreateML/MLSoundClassifier/DataSource/features(table:featureColumn:labelColumn:parameters:))

Creates a data source from a data table of audio features.

[`case featuresDataFrame(DataFrame, featureColumn: String, labelColumn: String, parameters: MLSoundClassifier.FeatureExtractionParameters)`](/documentation/CreateML/MLSoundClassifier/DataSource/featuresDataFrame(_:featureColumn:labelColumn:parameters:))

Creates a data source from a data frame of audio features.

[`struct FeatureExtractionParameters`](/documentation/CreateML/MLSoundClassifier/FeatureExtractionParameters)

Parameters that affect the process of extracting sound features from audio files.

### Retrieving the data

[`func labeledSounds() throws -> [String : [URL]]`](/documentation/CreateML/MLSoundClassifier/DataSource/labeledSounds())

Generates a dictionary of the data source’s labeled audio files.

### Partitioning the data

[`func stratifiedSplit(proportions: [Double], seed: Int) throws -> [[String : [URL]]]`](/documentation/CreateML/MLSoundClassifier/DataSource/stratifiedSplit(proportions:seed:))

Generates an array of labeled audio dictionaries by splitting the data source into strata.

[`func stratifiedSplit<RNG>(proportions: [Double], generator: inout RNG) throws -> [[String : [URL]]]`](/documentation/CreateML/MLSoundClassifier/DataSource/stratifiedSplit(proportions:generator:))

Generates an array of labeled audio dictionaries by splitting the data source into strata using the
random-number generator.



---

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)