No project description provided
Project description
ood_detectors
OOD Detectors is a Python package that offers a suite of algorithms designed to identify out-of-distribution samples in datasets. This is crucial for maintaining the reliability and accuracy of machine learning models when faced with unfamiliar data.
Table of Contents
Installation
To install OOD Detectors, run the following command:
pip install ood_detectors
Usage
This package includes several OOD detection algorithms, each tailored to different aspects of OOD detection:
-
DDM_Likelihood: A likelihood-based detector that utilizes score-based denoising diffusion models (DDM) to map complex distributions to known ones.
-
Residual: This method employs the least significant eigen vector for OOD detection.
All detectors share a common interface:
- Initialize the detector with necessary hyperparameters.
- Fit the model using fit() with the training data.
- Use predict() to obtain OOD scores for new data samples.
Example
from ood_detectors import DDM_Likelihood
ood_detector = DDM_Likelihood()
ood_detector.fit(train_data, n_epochs, batch_size)
scores = ood_detector.predict(test_data, batch_size)
from ood_detectors import Residual
ood_detector = Residual()
ood_detector.fit(train_data)
scores = ood_detector.predict(test_data)
Evaluate
To assess the performance of the OOD detectors, you can utilize the following metrics:
- AUC: Area under the ROC curve
- FPR95: False positive rate when the true positive rate is 95%
import ood_detectors.eval_utils as eval_utils
score_id = model_residual.predict(train_data)
score_ref = model_residual.predict(reference_data)
print(f"Train AUC: {eval_utils.auc(-score_ref, -score_id):.2%}")
print(f"Train FPR95: {eval_utils.fpr95(-score_ref, -score_id):.2%}")
results = eval_utils.eval_ood(model, train_data, reference_data, ood_data, batch_size, verbose=False)
plot_utils.plot(results, id_name, ood_names, encoder=embedding, model=model.__class__.__name__,
train_loss=train_loss,
config=conf,
)
License
ood_detectors
is distributed under the terms of the apache-2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ood_detectors-0.0.5.tar.gz
.
File metadata
- Download URL: ood_detectors-0.0.5.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0e7f81f9e033056d83bd03da9ff56649b72028096a289570be200d47f8609d7 |
|
MD5 | 484e889e3d6233b569b7b9ad1043ab7c |
|
BLAKE2b-256 | 604d159cbe2b8256b8d7f63d0f1ab390be99aca937a58762a588cf681669d1e5 |
File details
Details for the file ood_detectors-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: ood_detectors-0.0.5-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 642e7dbc71ec642083a882d962b04d3af283015038d9bbfb1753b1417d195f41 |
|
MD5 | 8d695b363d521f9ebc0ef960c5da5219 |
|
BLAKE2b-256 | 5451536b1194be3c934a8fbdcd13a7ad90b0b484ae72739672f012759e19f992 |