{"id":20910,"library":"alibi-detect","title":"Alibi Detect","description":"A Python library for outlier detection, adversarial detection, concept drift detection, and explainability. Supports TensorFlow, PyTorch, and scikit-learn backends. Current version 0.13.0, with quarterly releases.","status":"active","version":"0.13.0","language":"python","source_language":"en","source_url":"https://github.com/SeldonIO/alibi-detect","tags":["outlier-detection","drift-detection","anomaly-detection","machine-learning","explainability"],"install":[{"cmd":"pip install alibi-detect","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for TensorFlow-based detectors and legacy saving/loading (environment variable TF_USE_LEGACY_KERAS=1 needed for v0.13.0).","package":"tensorflow","optional":true},{"reason":"Optional for PyTorch-based detectors.","package":"torch","optional":true},{"reason":"Required for certain detectors and metrics.","package":"scikit-learn","optional":false}],"imports":[{"note":"Detectors are in submodules like alibi_detect.od, alibi_detect.cd, alibi_detect.ad.","wrong":"from alibi_detect import OutlierAENN","symbol":"outlier_detector","correct":"from alibi_detect.od import OutlierAENN"},{"note":"Drift detectors are in alibi_detect.cd (concept drift) not a separate drift module.","wrong":"from alibi_detect.drift import MMDDrift","symbol":"drift_detector","correct":"from alibi_detect.cd import MMDDrift"}],"quickstart":{"code":"from alibi_detect.cd import MMDDrift\nfrom alibi_detect.utils.data import create_outlier_batch\nimport numpy as np\n# create some reference data\nnp.random.seed(0)\nref_data = np.random.randn(100, 10)\n# initialize detector\ncd = MMDDrift(ref_data, p_val=0.05)\n# detect drift on new data\nx_new = np.random.randn(100, 10)\npreds = cd.predict(x_new)\nprint(preds)","lang":"python","description":"Basic drift detection with MMDDrift."},"warnings":[{"fix":"Set os.environ['TF_USE_LEGACY_KERAS'] = '1' before importing tensorflow or alibi_detect.","message":"In v0.13.0, TensorFlow backend requires setting environment variable TF_USE_LEGACY_KERAS=1 to use legacy Keras for saving/loading detectors with legacy=True or loading old pickles.","severity":"breaking","affected_versions":"0.13.0"},{"fix":"Ensure pydantic<2 or use the shim; check if your code uses internal Pydantic API.","message":"From v0.12.0, Pydantic v2 is supported via a v1 shim. Code relying on Pydantic v1 imports may break if v2 is installed.","severity":"breaking","affected_versions":">=0.12.0"},{"fix":"Always set TF_USE_LEGACY_KERAS=1 when using TensorFlow backend, even if not saving/loading legacy files.","message":"When saving or loading detectors, the environment variable TF_USE_LEGACY_KERAS may need to be set consistently across sessions. Failure causes cryptic tensorflow errors.","severity":"gotcha","affected_versions":">=0.13.0"},{"fix":"Upgrade Python to 3.9+.","message":"Python 3.7 support was dropped in v0.11.4. Python 3.11 support added in v0.11.3, Python 3.12 in v0.13.0.","severity":"deprecated","affected_versions":">=0.11.4"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install alibi-detect","cause":"Library not installed or installed with wrong name.","error":"ModuleNotFoundError: No module named 'alibi_detect'"},{"fix":"Use: from alibi_detect.cd import MMDDrift","cause":"Wrong import path - drift detectors are in alibi_detect.cd submodule.","error":"ImportError: cannot import name 'MMDDrift' from 'alibi_detect'"},{"fix":"Set os.environ['TF_USE_LEGACY_KERAS'] = '1' before any tensorflow import.","cause":"Saving/loading detector without setting TF_USE_LEGACY_KERAS=1 when using TensorFlow 2.16+.","error":"tensorflow.python.framework.errors_impl.NotFoundError: No such file or directory: '.../model.h5'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}