<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.steps.classifiers.FastTextClassifier.html -->
# FastTextClassifier

**`class FastTextClassifier(config)`**

Bases: [`Classifier`](squirro.lib.nlp.steps.classifiers.Classifier.md#squirro.lib.nlp.steps.classifiers.Classifier)

The fastText [`Classifier`](squirro.lib.nlp.steps.classifiers.Classifier.md#squirro.lib.nlp.steps.classifiers.Classifier) uses the [fastText](https://fasttext.cc/) library for text embedding and classification provided by Facebook’s AI Research lab.

**Input** - all input fields need to be of type [`str`](https://docs.python.org/3.11/library/stdtypes.html#str).

**Output** - the output field is filled with data of type [`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict) { [`str`](https://docs.python.org/3.11/library/stdtypes.html#str): [`float`](https://docs.python.org/3.11/library/functions.html#float) }. The key of the [`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict) is the predicted class name and the value is the probability/confidence returned by the model.

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – fasttext
- `cutoff` ([`int`](https://docs.python.org/3.11/library/functions.html#int)`, ``100000`) – Cutoff for quantization
- `learning_rate` ([`float`](https://docs.python.org/3.11/library/functions.html#float)`, ``1.0`) – Learning rate
- `min_count` ([`int`](https://docs.python.org/3.11/library/functions.html#int)`, ``1`) – Minimum number of words appearances to be included in dictionary
- `min_prob` ([`float`](https://docs.python.org/3.11/library/functions.html#float)`, ``0.0`) – Minimum prediction probability to return
- `n_epochs` ([`int`](https://docs.python.org/3.11/library/functions.html#int)`, ``25`) – Number of training epochs
- `n_grams` ([`int`](https://docs.python.org/3.11/library/functions.html#int)`, ``2`) – N of N-grams
- `n_predictions` ([`int`](https://docs.python.org/3.11/library/functions.html#int)`, ``None`) – Number of label predictions to return.
  By default this will be the number of unique labels.
- `quantize` ([`bool`](https://docs.python.org/3.11/library/functions.html#bool)`, ``False`) – Whether or not to quantize the model

**Example**

```json
{
    "step": "classifier",
    "type": "fasttext",
    "input_fields": ["extract"],
    "output_field": "prediction",
    "label_field": "label",
}
```

Methods SummaryMethods Documentation

**`clean()`**

Clean step

**`load()`**

Load a step

**`process_doc(doc)`**

Process a document

Parameters

`doc` ([`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)) – Document

Returns

Processed document

Return type

[Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)

**`save()`**

Save a step

**`train(docs)`**

Train on a step of a set of documents

Parameters

`docs` (`generator``(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – Generator of documents

Returns

Generator of processed documents

Return type

generator([Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document))
