Skip to main content

A tutorial of NBDev, its use cases and making libraries from it.

Project description

OOD Detection

This library is used for OOD Detection where a model encounters new classes at test time that were not seen during training. The goal is to detect that such inputs do not belong to any of the training classes.

flowchart LR
  A[Feature\nEmbeddings] --> C{OOD Detection}
  B[In Distribution\nLabels] --> C
  C --> F[Uncertainty Score]
  F --> D[Out of Distribtuion]
  F --> E[In Distribtuion]

Install

pip install ood_detection

Example Usage

import numpy as np
from ood_detection.core import OODMetric # imports OODMetric class and other utility functions
train_embedding = np.random.standard_normal((32, 2048))
train_labels = np.random.randint(low=0, high=5, size=(32,))
ood = OODMetric(train_embedding, train_labels)
test_embedding = np.random.standard_normal((32, 2048)) # test embedding from same distribution
scores = ood.compute_rmd(test_embedding) # compute relative mahalanobis distance
print(scores)
[ 1.16065497e+13 -1.37269901e+13  3.54920865e+12  4.75570475e+12
 -4.90615930e+12 -2.63622848e+12 -5.22489520e+11 -7.67105637e+12
  1.30991140e+12 -5.38689280e+12  2.71026479e+12 -4.07842659e+13
 -1.01482832e+13 -2.18136787e+13 -6.53841964e+12 -1.70525347e+13
  1.06493867e+13 -2.04729993e+13  4.68809372e+12 -6.11747086e+12
  1.09862330e+13  1.03001857e+13 -2.91312276e+13 -9.26086735e+12
  7.23079505e+12  7.26673743e+12 -4.73734980e+13  3.17798849e+12
  1.99687662e+13  2.99860166e+12  9.86244208e+11  8.76676896e+12]

Built using NBDev

This OOD Detection library was built in a jupyter notebook with proper documentation and test cases. These test cases are verified before they are published to Github Pages, PyPi, Conda etc.

I’ve written down a NBDev Tutorial explaining the thought process of Jeremy Howard and folks at FastAI behind building it. The tutorial covers about what it can do and how it is an amazing tool with support for building softwares following the best coding principles.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ood_detection-0.0.3.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ood_detection-0.0.3-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file ood_detection-0.0.3.tar.gz.

File metadata

  • Download URL: ood_detection-0.0.3.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for ood_detection-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cee84cb2651ffdf2fc491e16c13e19a147f440263129f21766af8cf3281d5bfa
MD5 c973a8eb26c2155a338fcc661ae9c3f6
BLAKE2b-256 f2f698c0995c3b1cda6a8cfe89c066b95587ee7c17b7a95c6d683976c1fef0e4

See more details on using hashes here.

File details

Details for the file ood_detection-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: ood_detection-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for ood_detection-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d6d96d9a2000ad1dd8e168ff540c7a9db12b3f69c02be713f0d6fb2bde5b62f7
MD5 c456f21c80534abcdb67de8b0e41652f
BLAKE2b-256 8518eb8fe9b66af066b4b9cc0660cd22f249d0b123c0cacd78eb740119919225

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page