---
title: MLTextClassifier
framework: createml
role: symbol
role_heading: Structure
path: createml/mltextclassifier
---

# MLTextClassifier

A model you train to classify natural language text.

## Declaration

```swift
struct MLTextClassifier
```

## Mentioned in

Creating a text classifier model

## Overview

Overview Use a text classifier to train a machine learning model you can include in your app to classify natural language text. The model learns to associate labels with features of the input text, which can be sentences, paragraphs, or even entire documents. After you train a text classifier, you save it to a Core ML model file. You then use an instance of the NLModel class from the Natural Language framework to read the model file into your app.

## Topics

### Creating and training a text classifier

- [init(trainingData:parameters:)](createml/mltextclassifier/init(trainingdata:parameters:).md)
- [init(trainingData:textColumn:labelColumn:parameters:)](createml/mltextclassifier/init(trainingdata:textcolumn:labelcolumn:parameters:).md)
- [MLTextClassifier.DataSource](createml/mltextclassifier/datasource.md)
- [MLTextClassifier.ModelParameters](createml/mltextclassifier/modelparameters-swift.struct.md)
- [modelParameters](createml/mltextclassifier/modelparameters-swift.property.md)

### Evaluating a text classifier

- [evaluation(on:)](createml/mltextclassifier/evaluation(on:).md)
- [evaluation(on:textColumn:labelColumn:)](createml/mltextclassifier/evaluation(on:textcolumn:labelcolumn:).md)
- [trainingMetrics](createml/mltextclassifier/trainingmetrics.md)
- [validationMetrics](createml/mltextclassifier/validationmetrics.md)

### Testing a text classifier

- [prediction(from:)](createml/mltextclassifier/prediction(from:).md)
- [predictions(from:)](createml/mltextclassifier/predictions(from:).md)
- [predictionWithConfidence(from:)](createml/mltextclassifier/predictionwithconfidence(from:).md)
- [predictionsWithConfidence(from:)](createml/mltextclassifier/predictionswithconfidence(from:).md)

### Saving a text classifier

- [write(to:metadata:)](createml/mltextclassifier/write(to:metadata:).md)
- [write(toFile:metadata:)](createml/mltextclassifier/write(tofile:metadata:).md)

### Describing a text classifier

- [model](createml/mltextclassifier/model.md)
- [description](createml/mltextclassifier/description.md)
- [debugDescription](createml/mltextclassifier/debugdescription.md)
- [playgroundDescription](createml/mltextclassifier/playgrounddescription.md)

### Supporting types

- [MLTextClassifier.FeatureExtractorType](createml/mltextclassifier/featureextractortype.md)
- [MLTextClassifier.ModelAlgorithmType](createml/mltextclassifier/modelalgorithmtype.md)

### Default Implementations

- [CustomDebugStringConvertible Implementations](createml/mltextclassifier/customdebugstringconvertible-implementations.md)
- [CustomPlaygroundDisplayConvertible Implementations](createml/mltextclassifier/customplaygrounddisplayconvertible-implementations.md)
- [CustomStringConvertible Implementations](createml/mltextclassifier/customstringconvertible-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomPlaygroundDisplayConvertible](swift/customplaygrounddisplayconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Escapable](swift/escapable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Text models

- [Creating a text classifier model](createml/creating-a-text-classifier-model.md)
- [Creating a word tagger model](createml/creating-a-word-tagger-model.md)
- [MLWordTagger](createml/mlwordtagger.md)
- [MLGazetteer](createml/mlgazetteer.md)
- [MLWordEmbedding](createml/mlwordembedding.md)
