# Outliner Detection

Machine learning models do not extrapolate well outside of the training data distribution. In order to trust and reliably act on model predictions, it is crucial to monitor the distribution of incoming requests via different types of detectors. Outlier detectors aim to flag individual instances which do not follow the original training distribution.

| Package        | Version |
| -------------- | ------- |
| `alibi-detect` | `0.9.0` |

A [worked example with using the CIFAR10 task](https://github.com/SeldonIO/seldon-core/blob/master/docs-gb/examples/outlier_cifar10.html) is available. This example focuses on the serving infrastructure and discusses it in details.

The general framework shown in this example is to use the Seldon Core payload logger to pass requests to components that process them asynchronously. The results can be passed onwards to alterting systems.

![Example architecture](https://3905164823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPa9sGcGk4LhZOQJGCNxN%2Fuploads%2Fgit-blob-acf4dc4bc3bc11af170de7c21bc8907029cb33da%2Fanalytics.png?alt=media)

## Creating your own detector

For Alibi Detect outlier detectors that need to be trained you should

1. Use python 3.7 as the Seldon Alibi Detect Server also runs in python 3.7.10 when it loads your detector.
2. Follow the [Alibi Detect docs](https://docs.seldon.ai/alibi-detect) for your particular desired detector.
3. Save your detector using [save\_detector](https://docs.seldon.ai/alibi-detect/saving) method and store in the object store or PVC in your cluster. We support various cloud storage solutions through our [init container](https://docs.seldon.ai/seldon-core-1/configuration/servers/overview).

The runtime environment in our [Alibi Explain Detector](https://github.com/SeldonIO/seldon-core/tree/master/components/alibi-detect-server) is locked using [Poetry](https://python-poetry.org/). See our e2e example [here](https://docs.seldon.ai/seldon-core-1/tutorials/notebooks/cifar10_od_poetry) on how to use that definition to train your detector.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.seldon.ai/seldon-core-1/configuration/integrations/outlier_detection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
