
Alibi Detect は、外れ値、敵対的、ドリフト検出に特化したソース利用可能な Python ライブラリです。このパッケージは、表形式データ、テキスト、画像、時系列向けのオンラインおよびオフライン検出器の両方をカバーすることを目的としています。ドリフト検出では、TensorFlow と PyTorch の両バックエンドがサポートされています。
本番環境での外れ値と分布のモニタリングの重要性に関する背景については、論文 Monitoring and explainability of models in production に基づき、Alibi Detect に言及している Challenges in Deploying and Monitoring Machine Learning Systems ICML 2020 ワークショップのこの講演をご覧ください。
ドリフト検出の徹底的な入門については、Protecting Your Machine Learning Against Drift: An Introduction をご覧ください。この講演では、ドリフトとは何か、なぜそれを検出することが有益なのか、ドリフトのさまざまな種類、原則に基づいて検出する方法、そしてドリフト検出器の構造について説明しています。
パッケージ alibi-detect は以下からインストールできます:
pip を使用)conda/mamba を使用)
Prophet 時系列外れ値検出器を使用するには: ```bash
pip install alibi-detect[prophet]
conda-forge からインストールするには、mamba を使用することをお勧めします。 これは、base conda 環境に次のコマンドでインストールできます:```bash conda install mamba -n base -c conda-forge
alibi-detect をインストールするには:```bash
mamba install -c conda-forge alibi-detect
VAE outlier detector を使用して API を説明します。```python from alibi_detect.od import OutlierVAE from alibi_detect.saving import save_detector, load_detector
od = OutlierVAE(threshold=0.1, encoder_net=encoder_net, decoder_net=decoder_net, latent_dim=1024) od.fit(x_train)
preds = od.predict(x_test)
filepath = './my_detector/' save_detector(od, filepath) od = load_detector(filepath)
予測結果は、キーとして`meta`と`data`を持つ辞書で返されます。`meta`には検出器のメタデータが含まれ、`data`自体は実際の予測結果を含む辞書です。そこには、外れ値、敵対的サンプル、ドリフトの各スコアとしきい値、およびインスタンスが例えば外れ値であるかどうかといった予測結果が含まれます。正確な詳細はメソッドによって多少異なる場合があるため、読者には[サポートされているアルゴリズムの種類](https://docs.seldon.io/projects/alibi-detect/en/stable/overview/algorithms.html)をよく理解しておくことをお勧めします。
## サポートされているアルゴリズム
以下の表は、各アルゴリズムの推奨されるユースケースを示しています。*特徴量レベル* の列は、画像のピクセル単位など、特徴量レベルで検出が可能かどうかを示します。詳しくは、各検出器のドキュメントや原著論文へのリンク、およびサンプルを含む[アルゴリズムリファレンスリスト](#reference-list)を参照してください。
### 外れ値検出
| 検出器 | 表形式 | 画像 | 時系列 | テキスト | カテゴリ特徴量 | オンライン | 特徴量レベル |
|:---------------------|:-------:|:-----:|:-----------:|:----:|:--------------------:|:------:|:-------------:|
| Isolation Forest | ✔ | | | | ✔ | | |
| Mahalanobis Distance | ✔ | | | | ✔ | ✔ | |
| AE | ✔ | ✔ | | | | | ✔ |
| VAE | ✔ | ✔ | | | | | ✔ |
| AEGMM | ✔ | ✔ | | | | | |
| VAEGMM | ✔ | ✔ | | | | | |
| Likelihood Ratios | ✔ | ✔ | ✔ | | ✔ | | ✔ |
| Prophet | | | ✔ | | | | |
| Spectral Residual | | | ✔ | | | ✔ | ✔ |
| Seq2Seq | | | ✔ | | | | ✔ |
### 敵対的検出
| 検出器 | 表形式 | 画像 | 時系列 | テキスト | カテゴリ特徴量 | オンライン | 特徴量レベル |
| :--- | :---: | :---: |:-----------:|:----:|:--------------------:|:------:|:-------------:|
| Adversarial AE | ✔ | ✔ | | | | | |
| Model distillation | ✔ | ✔ | ✔ | ✔ | ✔ | | |
### ドリフト検出