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

**`class SklearnTFIDFEmbedder(config)`**

Bases: [`Embedder`](squirro.lib.nlp.steps.embedders.Embedder.md#squirro.lib.nlp.steps.embedders.Embedder)

The TFIDF [`Embedder`](squirro.lib.nlp.steps.embedders.Embedder.md#squirro.lib.nlp.steps.embedders.Embedder) encodes provided text based on the sklearn [TFIDF-Vectorizer](https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html).

**Input** - the input field needs 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 `numpy.ndarray`

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – sklearn_tfidf
- `model_kwargs` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)`, ``{}`) – Keyword arguments to pass on to sklearn TfidfVectorizer

**Example**

```json
{
    "step": "embedder",
    "type": "sklearn_tfidf",
    "name": "sklearn_tfidf",
    "input_field": "body",
    "model_kwargs": {
        "min_df": 5,
        "ngram_range": "1, 3"
    },
    "output_field": "embedded_body"
}
```

Methods SummaryMethods Documentation

**`load()`**

Load a step

**`process_batch(batch)`**

Process a batch of documents. If not defined will default to using
self.process_doc for each document in the batch.

Parameters

`batch` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – List of documents

Returns

List of processed documents

Return type

[list](https://docs.python.org/3.11/library/stdtypes.html#list)([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))
