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

**`class ThresholdFilter(config)`**

Bases: [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter)

The threshold [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter) removes weighted facets with values below threshold.

**Input** - all input fields need to be of type [`list`](https://docs.python.org/3.11/library/stdtypes.html#list) [[`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)] or [`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict) containing { [`str`](https://docs.python.org/3.11/library/stdtypes.html#str) : [`int`](https://docs.python.org/3.11/library/functions.html#int) or [`float`](https://docs.python.org/3.11/library/functions.html#float)}.

**Output - the output fields data format differs in the step config:**

- skip:True: No specific output format due to removal or marking to skip of the whole [`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document) if threshold isn’t met.
- flatten:False: all output fields are filled with data of type [`list`](https://docs.python.org/3.11/library/stdtypes.html#list) [[`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)] or [`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict) containing {[`str`](https://docs.python.org/3.11/library/stdtypes.html#str) : [`int`](https://docs.python.org/3.11/library/functions.html#int) or [`float`](https://docs.python.org/3.11/library/functions.html#float)}.
- flatten:True: all output fields are filled with data of type [`list`](https://docs.python.org/3.11/library/stdtypes.html#list) [[`str`](https://docs.python.org/3.11/library/stdtypes.html#str)] or [`str`](https://docs.python.org/3.11/library/stdtypes.html#str).

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – threshold
- `field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``None`) – Field to threshold
- `fields` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``None`) – List of fields to threshold
- `input_fields` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``None`) – List of fields to threshold from
- `output_fields` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``None`) – List of fields to threshold to
- `flatten` ([`bool`](https://docs.python.org/3.11/library/functions.html#bool)`, ``False`) – Whether or not to flatten the thresholded fields respectively remove the value of the dict in the field.
- `excluded_values` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`, ``[``]`) – Values that will not count towards the threshold.
- `threshold` ([`float`](https://docs.python.org/3.11/library/functions.html#float)`, ``0.5`) – Value under which the field will be removed.
- `skip` ([`bool`](https://docs.python.org/3.11/library/functions.html#bool)`, ``True`) – Whether or not to skip a doc below threshold.

**Example**

```json
{
    "step": "filter",
    "type": "threshold",
    "fields": ["prediction"],
    "flatten": true,
    "threshold": 0.5
}
```

Methods SummaryMethods Documentation

**`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)
