xplia 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- venv/Lib/site-packages/_distutils_hack/__init__.py +222 -0
- venv/Lib/site-packages/_distutils_hack/override.py +1 -0
- venv/Lib/site-packages/pip/__init__.py +13 -0
- venv/Lib/site-packages/pip/__main__.py +24 -0
- venv/Lib/site-packages/pip/__pip-runner__.py +50 -0
- venv/Lib/site-packages/pip/_internal/__init__.py +19 -0
- venv/Lib/site-packages/pip/_internal/build_env.py +311 -0
- venv/Lib/site-packages/pip/_internal/cache.py +292 -0
- venv/Lib/site-packages/pip/_internal/cli/__init__.py +4 -0
- venv/Lib/site-packages/pip/_internal/cli/autocompletion.py +171 -0
- venv/Lib/site-packages/pip/_internal/cli/base_command.py +236 -0
- venv/Lib/site-packages/pip/_internal/cli/cmdoptions.py +1074 -0
- venv/Lib/site-packages/pip/_internal/cli/command_context.py +27 -0
- venv/Lib/site-packages/pip/_internal/cli/main.py +79 -0
- venv/Lib/site-packages/pip/_internal/cli/main_parser.py +134 -0
- venv/Lib/site-packages/pip/_internal/cli/parser.py +294 -0
- venv/Lib/site-packages/pip/_internal/cli/progress_bars.py +68 -0
- venv/Lib/site-packages/pip/_internal/cli/req_command.py +508 -0
- venv/Lib/site-packages/pip/_internal/cli/spinners.py +159 -0
- venv/Lib/site-packages/pip/_internal/cli/status_codes.py +6 -0
- venv/Lib/site-packages/pip/_internal/commands/__init__.py +132 -0
- venv/Lib/site-packages/pip/_internal/commands/cache.py +222 -0
- venv/Lib/site-packages/pip/_internal/commands/check.py +54 -0
- venv/Lib/site-packages/pip/_internal/commands/completion.py +121 -0
- venv/Lib/site-packages/pip/_internal/commands/configuration.py +282 -0
- venv/Lib/site-packages/pip/_internal/commands/debug.py +199 -0
- venv/Lib/site-packages/pip/_internal/commands/download.py +147 -0
- venv/Lib/site-packages/pip/_internal/commands/freeze.py +108 -0
- venv/Lib/site-packages/pip/_internal/commands/hash.py +59 -0
- venv/Lib/site-packages/pip/_internal/commands/help.py +41 -0
- venv/Lib/site-packages/pip/_internal/commands/index.py +139 -0
- venv/Lib/site-packages/pip/_internal/commands/inspect.py +92 -0
- venv/Lib/site-packages/pip/_internal/commands/install.py +778 -0
- venv/Lib/site-packages/pip/_internal/commands/list.py +368 -0
- venv/Lib/site-packages/pip/_internal/commands/search.py +174 -0
- venv/Lib/site-packages/pip/_internal/commands/show.py +189 -0
- venv/Lib/site-packages/pip/_internal/commands/uninstall.py +113 -0
- venv/Lib/site-packages/pip/_internal/commands/wheel.py +183 -0
- venv/Lib/site-packages/pip/_internal/configuration.py +381 -0
- venv/Lib/site-packages/pip/_internal/distributions/__init__.py +21 -0
- venv/Lib/site-packages/pip/_internal/distributions/base.py +39 -0
- venv/Lib/site-packages/pip/_internal/distributions/installed.py +23 -0
- venv/Lib/site-packages/pip/_internal/distributions/sdist.py +150 -0
- venv/Lib/site-packages/pip/_internal/distributions/wheel.py +34 -0
- venv/Lib/site-packages/pip/_internal/exceptions.py +733 -0
- venv/Lib/site-packages/pip/_internal/index/__init__.py +2 -0
- venv/Lib/site-packages/pip/_internal/index/collector.py +505 -0
- venv/Lib/site-packages/pip/_internal/index/package_finder.py +1029 -0
- venv/Lib/site-packages/pip/_internal/index/sources.py +223 -0
- venv/Lib/site-packages/pip/_internal/locations/__init__.py +467 -0
- venv/Lib/site-packages/pip/_internal/locations/_distutils.py +173 -0
- venv/Lib/site-packages/pip/_internal/locations/_sysconfig.py +213 -0
- venv/Lib/site-packages/pip/_internal/locations/base.py +81 -0
- venv/Lib/site-packages/pip/_internal/main.py +12 -0
- venv/Lib/site-packages/pip/_internal/metadata/__init__.py +127 -0
- venv/Lib/site-packages/pip/_internal/metadata/_json.py +84 -0
- venv/Lib/site-packages/pip/_internal/metadata/base.py +688 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/__init__.py +4 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_compat.py +55 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_dists.py +224 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_envs.py +188 -0
- venv/Lib/site-packages/pip/_internal/metadata/pkg_resources.py +270 -0
- venv/Lib/site-packages/pip/_internal/models/__init__.py +2 -0
- venv/Lib/site-packages/pip/_internal/models/candidate.py +34 -0
- venv/Lib/site-packages/pip/_internal/models/direct_url.py +237 -0
- venv/Lib/site-packages/pip/_internal/models/format_control.py +80 -0
- venv/Lib/site-packages/pip/_internal/models/index.py +28 -0
- venv/Lib/site-packages/pip/_internal/models/installation_report.py +53 -0
- venv/Lib/site-packages/pip/_internal/models/link.py +581 -0
- venv/Lib/site-packages/pip/_internal/models/scheme.py +31 -0
- venv/Lib/site-packages/pip/_internal/models/search_scope.py +132 -0
- venv/Lib/site-packages/pip/_internal/models/selection_prefs.py +51 -0
- venv/Lib/site-packages/pip/_internal/models/target_python.py +110 -0
- venv/Lib/site-packages/pip/_internal/models/wheel.py +92 -0
- venv/Lib/site-packages/pip/_internal/network/__init__.py +2 -0
- venv/Lib/site-packages/pip/_internal/network/auth.py +561 -0
- venv/Lib/site-packages/pip/_internal/network/cache.py +69 -0
- venv/Lib/site-packages/pip/_internal/network/download.py +186 -0
- venv/Lib/site-packages/pip/_internal/network/lazy_wheel.py +210 -0
- venv/Lib/site-packages/pip/_internal/network/session.py +519 -0
- venv/Lib/site-packages/pip/_internal/network/utils.py +96 -0
- venv/Lib/site-packages/pip/_internal/network/xmlrpc.py +60 -0
- venv/Lib/site-packages/pip/_internal/operations/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/operations/build/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/operations/build/build_tracker.py +124 -0
- venv/Lib/site-packages/pip/_internal/operations/build/metadata.py +39 -0
- venv/Lib/site-packages/pip/_internal/operations/build/metadata_editable.py +41 -0
- venv/Lib/site-packages/pip/_internal/operations/build/metadata_legacy.py +74 -0
- venv/Lib/site-packages/pip/_internal/operations/build/wheel.py +37 -0
- venv/Lib/site-packages/pip/_internal/operations/build/wheel_editable.py +46 -0
- venv/Lib/site-packages/pip/_internal/operations/build/wheel_legacy.py +102 -0
- venv/Lib/site-packages/pip/_internal/operations/check.py +187 -0
- venv/Lib/site-packages/pip/_internal/operations/freeze.py +255 -0
- venv/Lib/site-packages/pip/_internal/operations/install/__init__.py +2 -0
- venv/Lib/site-packages/pip/_internal/operations/install/editable_legacy.py +46 -0
- venv/Lib/site-packages/pip/_internal/operations/install/wheel.py +740 -0
- venv/Lib/site-packages/pip/_internal/operations/prepare.py +743 -0
- venv/Lib/site-packages/pip/_internal/pyproject.py +179 -0
- venv/Lib/site-packages/pip/_internal/req/__init__.py +92 -0
- venv/Lib/site-packages/pip/_internal/req/constructors.py +506 -0
- venv/Lib/site-packages/pip/_internal/req/req_file.py +552 -0
- venv/Lib/site-packages/pip/_internal/req/req_install.py +874 -0
- venv/Lib/site-packages/pip/_internal/req/req_set.py +119 -0
- venv/Lib/site-packages/pip/_internal/req/req_uninstall.py +650 -0
- venv/Lib/site-packages/pip/_internal/resolution/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/base.py +20 -0
- venv/Lib/site-packages/pip/_internal/resolution/legacy/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/legacy/resolver.py +600 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/base.py +141 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py +555 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/factory.py +730 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +155 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/provider.py +255 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/reporter.py +80 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/requirements.py +165 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/resolver.py +299 -0
- venv/Lib/site-packages/pip/_internal/self_outdated_check.py +242 -0
- venv/Lib/site-packages/pip/_internal/utils/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/utils/_jaraco_text.py +109 -0
- venv/Lib/site-packages/pip/_internal/utils/_log.py +38 -0
- venv/Lib/site-packages/pip/_internal/utils/appdirs.py +52 -0
- venv/Lib/site-packages/pip/_internal/utils/compat.py +63 -0
- venv/Lib/site-packages/pip/_internal/utils/compatibility_tags.py +165 -0
- venv/Lib/site-packages/pip/_internal/utils/datetime.py +11 -0
- venv/Lib/site-packages/pip/_internal/utils/deprecation.py +120 -0
- venv/Lib/site-packages/pip/_internal/utils/direct_url_helpers.py +87 -0
- venv/Lib/site-packages/pip/_internal/utils/egg_link.py +72 -0
- venv/Lib/site-packages/pip/_internal/utils/encoding.py +36 -0
- venv/Lib/site-packages/pip/_internal/utils/entrypoints.py +84 -0
- venv/Lib/site-packages/pip/_internal/utils/filesystem.py +153 -0
- venv/Lib/site-packages/pip/_internal/utils/filetypes.py +27 -0
- venv/Lib/site-packages/pip/_internal/utils/glibc.py +88 -0
- venv/Lib/site-packages/pip/_internal/utils/hashes.py +151 -0
- venv/Lib/site-packages/pip/_internal/utils/inject_securetransport.py +35 -0
- venv/Lib/site-packages/pip/_internal/utils/logging.py +348 -0
- venv/Lib/site-packages/pip/_internal/utils/misc.py +735 -0
- venv/Lib/site-packages/pip/_internal/utils/models.py +39 -0
- venv/Lib/site-packages/pip/_internal/utils/packaging.py +57 -0
- venv/Lib/site-packages/pip/_internal/utils/setuptools_build.py +146 -0
- venv/Lib/site-packages/pip/_internal/utils/subprocess.py +260 -0
- venv/Lib/site-packages/pip/_internal/utils/temp_dir.py +246 -0
- venv/Lib/site-packages/pip/_internal/utils/unpacking.py +257 -0
- venv/Lib/site-packages/pip/_internal/utils/urls.py +62 -0
- venv/Lib/site-packages/pip/_internal/utils/virtualenv.py +104 -0
- venv/Lib/site-packages/pip/_internal/utils/wheel.py +136 -0
- venv/Lib/site-packages/pip/_internal/vcs/__init__.py +15 -0
- venv/Lib/site-packages/pip/_internal/vcs/bazaar.py +112 -0
- venv/Lib/site-packages/pip/_internal/vcs/git.py +526 -0
- venv/Lib/site-packages/pip/_internal/vcs/mercurial.py +163 -0
- venv/Lib/site-packages/pip/_internal/vcs/subversion.py +324 -0
- venv/Lib/site-packages/pip/_internal/vcs/versioncontrol.py +705 -0
- venv/Lib/site-packages/pip/_internal/wheel_builder.py +355 -0
- venv/Lib/site-packages/pip/_vendor/__init__.py +120 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/__init__.py +18 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/_cmd.py +61 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py +137 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/cache.py +65 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +9 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +188 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +39 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/compat.py +32 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/controller.py +439 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/filewrapper.py +111 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/heuristics.py +139 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py +190 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/wrapper.py +33 -0
- venv/Lib/site-packages/pip/_vendor/certifi/__init__.py +4 -0
- venv/Lib/site-packages/pip/_vendor/certifi/__main__.py +12 -0
- venv/Lib/site-packages/pip/_vendor/certifi/core.py +108 -0
- venv/Lib/site-packages/pip/_vendor/chardet/__init__.py +115 -0
- venv/Lib/site-packages/pip/_vendor/chardet/big5freq.py +386 -0
- venv/Lib/site-packages/pip/_vendor/chardet/big5prober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/chardistribution.py +261 -0
- venv/Lib/site-packages/pip/_vendor/chardet/charsetgroupprober.py +106 -0
- venv/Lib/site-packages/pip/_vendor/chardet/charsetprober.py +147 -0
- venv/Lib/site-packages/pip/_vendor/chardet/cli/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/chardet/cli/chardetect.py +112 -0
- venv/Lib/site-packages/pip/_vendor/chardet/codingstatemachine.py +90 -0
- venv/Lib/site-packages/pip/_vendor/chardet/codingstatemachinedict.py +19 -0
- venv/Lib/site-packages/pip/_vendor/chardet/cp949prober.py +49 -0
- venv/Lib/site-packages/pip/_vendor/chardet/enums.py +85 -0
- venv/Lib/site-packages/pip/_vendor/chardet/escprober.py +102 -0
- venv/Lib/site-packages/pip/_vendor/chardet/escsm.py +261 -0
- venv/Lib/site-packages/pip/_vendor/chardet/eucjpprober.py +102 -0
- venv/Lib/site-packages/pip/_vendor/chardet/euckrfreq.py +196 -0
- venv/Lib/site-packages/pip/_vendor/chardet/euckrprober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/euctwfreq.py +388 -0
- venv/Lib/site-packages/pip/_vendor/chardet/euctwprober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/gb2312freq.py +284 -0
- venv/Lib/site-packages/pip/_vendor/chardet/gb2312prober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/hebrewprober.py +316 -0
- venv/Lib/site-packages/pip/_vendor/chardet/jisfreq.py +325 -0
- venv/Lib/site-packages/pip/_vendor/chardet/johabfreq.py +2382 -0
- venv/Lib/site-packages/pip/_vendor/chardet/johabprober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/jpcntx.py +238 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langbulgarianmodel.py +4649 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langgreekmodel.py +4397 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langhebrewmodel.py +4380 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langhungarianmodel.py +4649 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langrussianmodel.py +5725 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langthaimodel.py +4380 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langturkishmodel.py +4380 -0
- venv/Lib/site-packages/pip/_vendor/chardet/latin1prober.py +147 -0
- venv/Lib/site-packages/pip/_vendor/chardet/macromanprober.py +162 -0
- venv/Lib/site-packages/pip/_vendor/chardet/mbcharsetprober.py +95 -0
- venv/Lib/site-packages/pip/_vendor/chardet/mbcsgroupprober.py +57 -0
- venv/Lib/site-packages/pip/_vendor/chardet/mbcssm.py +661 -0
- venv/Lib/site-packages/pip/_vendor/chardet/metadata/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/chardet/metadata/languages.py +352 -0
- venv/Lib/site-packages/pip/_vendor/chardet/resultdict.py +16 -0
- venv/Lib/site-packages/pip/_vendor/chardet/sbcharsetprober.py +162 -0
- venv/Lib/site-packages/pip/_vendor/chardet/sbcsgroupprober.py +88 -0
- venv/Lib/site-packages/pip/_vendor/chardet/sjisprober.py +105 -0
- venv/Lib/site-packages/pip/_vendor/chardet/universaldetector.py +362 -0
- venv/Lib/site-packages/pip/_vendor/chardet/utf1632prober.py +225 -0
- venv/Lib/site-packages/pip/_vendor/chardet/utf8prober.py +82 -0
- venv/Lib/site-packages/pip/_vendor/chardet/version.py +9 -0
- venv/Lib/site-packages/pip/_vendor/colorama/__init__.py +7 -0
- venv/Lib/site-packages/pip/_vendor/colorama/ansi.py +102 -0
- venv/Lib/site-packages/pip/_vendor/colorama/ansitowin32.py +277 -0
- venv/Lib/site-packages/pip/_vendor/colorama/initialise.py +121 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/__init__.py +1 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/ansi_test.py +76 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/ansitowin32_test.py +294 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/initialise_test.py +189 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/isatty_test.py +57 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/utils.py +49 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/winterm_test.py +131 -0
- venv/Lib/site-packages/pip/_vendor/colorama/win32.py +180 -0
- venv/Lib/site-packages/pip/_vendor/colorama/winterm.py +195 -0
- venv/Lib/site-packages/pip/_vendor/distlib/__init__.py +23 -0
- venv/Lib/site-packages/pip/_vendor/distlib/compat.py +1116 -0
- venv/Lib/site-packages/pip/_vendor/distlib/database.py +1350 -0
- venv/Lib/site-packages/pip/_vendor/distlib/index.py +508 -0
- venv/Lib/site-packages/pip/_vendor/distlib/locators.py +1300 -0
- venv/Lib/site-packages/pip/_vendor/distlib/manifest.py +393 -0
- venv/Lib/site-packages/pip/_vendor/distlib/markers.py +152 -0
- venv/Lib/site-packages/pip/_vendor/distlib/metadata.py +1076 -0
- venv/Lib/site-packages/pip/_vendor/distlib/resources.py +358 -0
- venv/Lib/site-packages/pip/_vendor/distlib/scripts.py +437 -0
- venv/Lib/site-packages/pip/_vendor/distlib/util.py +1932 -0
- venv/Lib/site-packages/pip/_vendor/distlib/version.py +739 -0
- venv/Lib/site-packages/pip/_vendor/distlib/wheel.py +1082 -0
- venv/Lib/site-packages/pip/_vendor/distro/__init__.py +54 -0
- venv/Lib/site-packages/pip/_vendor/distro/__main__.py +4 -0
- venv/Lib/site-packages/pip/_vendor/distro/distro.py +1399 -0
- venv/Lib/site-packages/pip/_vendor/idna/__init__.py +44 -0
- venv/Lib/site-packages/pip/_vendor/idna/codec.py +112 -0
- venv/Lib/site-packages/pip/_vendor/idna/compat.py +13 -0
- venv/Lib/site-packages/pip/_vendor/idna/core.py +400 -0
- venv/Lib/site-packages/pip/_vendor/idna/idnadata.py +2151 -0
- venv/Lib/site-packages/pip/_vendor/idna/intranges.py +54 -0
- venv/Lib/site-packages/pip/_vendor/idna/package_data.py +2 -0
- venv/Lib/site-packages/pip/_vendor/idna/uts46data.py +8600 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/__init__.py +57 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/exceptions.py +48 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/ext.py +193 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/fallback.py +1010 -0
- venv/Lib/site-packages/pip/_vendor/packaging/__about__.py +26 -0
- venv/Lib/site-packages/pip/_vendor/packaging/__init__.py +25 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_manylinux.py +301 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_musllinux.py +136 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_structures.py +61 -0
- venv/Lib/site-packages/pip/_vendor/packaging/markers.py +304 -0
- venv/Lib/site-packages/pip/_vendor/packaging/requirements.py +146 -0
- venv/Lib/site-packages/pip/_vendor/packaging/specifiers.py +802 -0
- venv/Lib/site-packages/pip/_vendor/packaging/tags.py +487 -0
- venv/Lib/site-packages/pip/_vendor/packaging/utils.py +136 -0
- venv/Lib/site-packages/pip/_vendor/packaging/version.py +504 -0
- venv/Lib/site-packages/pip/_vendor/pkg_resources/__init__.py +3361 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/__init__.py +566 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/__main__.py +53 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/android.py +210 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/api.py +223 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/macos.py +91 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/unix.py +223 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/version.py +4 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/windows.py +255 -0
- venv/Lib/site-packages/pip/_vendor/pygments/__init__.py +82 -0
- venv/Lib/site-packages/pip/_vendor/pygments/__main__.py +17 -0
- venv/Lib/site-packages/pip/_vendor/pygments/cmdline.py +668 -0
- venv/Lib/site-packages/pip/_vendor/pygments/console.py +70 -0
- venv/Lib/site-packages/pip/_vendor/pygments/filter.py +71 -0
- venv/Lib/site-packages/pip/_vendor/pygments/filters/__init__.py +940 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatter.py +124 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/__init__.py +158 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/_mapping.py +23 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/bbcode.py +108 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/groff.py +170 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/html.py +989 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/img.py +645 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/irc.py +154 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/latex.py +521 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/other.py +161 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/pangomarkup.py +83 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/rtf.py +146 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/svg.py +188 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/terminal.py +127 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/terminal256.py +338 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexer.py +943 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/__init__.py +362 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/_mapping.py +559 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/python.py +1198 -0
- venv/Lib/site-packages/pip/_vendor/pygments/modeline.py +43 -0
- venv/Lib/site-packages/pip/_vendor/pygments/plugin.py +88 -0
- venv/Lib/site-packages/pip/_vendor/pygments/regexopt.py +91 -0
- venv/Lib/site-packages/pip/_vendor/pygments/scanner.py +104 -0
- venv/Lib/site-packages/pip/_vendor/pygments/sphinxext.py +217 -0
- venv/Lib/site-packages/pip/_vendor/pygments/style.py +197 -0
- venv/Lib/site-packages/pip/_vendor/pygments/styles/__init__.py +103 -0
- venv/Lib/site-packages/pip/_vendor/pygments/token.py +213 -0
- venv/Lib/site-packages/pip/_vendor/pygments/unistring.py +153 -0
- venv/Lib/site-packages/pip/_vendor/pygments/util.py +330 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/__init__.py +322 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/actions.py +217 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/common.py +432 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/core.py +6115 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/diagram/__init__.py +656 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/exceptions.py +299 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/helpers.py +1100 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/results.py +796 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/testing.py +331 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/unicode.py +361 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/util.py +284 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/__init__.py +23 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_compat.py +8 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_impl.py +330 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/__init__.py +18 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py +353 -0
- venv/Lib/site-packages/pip/_vendor/requests/__init__.py +182 -0
- venv/Lib/site-packages/pip/_vendor/requests/__version__.py +14 -0
- venv/Lib/site-packages/pip/_vendor/requests/_internal_utils.py +50 -0
- venv/Lib/site-packages/pip/_vendor/requests/adapters.py +538 -0
- venv/Lib/site-packages/pip/_vendor/requests/api.py +157 -0
- venv/Lib/site-packages/pip/_vendor/requests/auth.py +315 -0
- venv/Lib/site-packages/pip/_vendor/requests/certs.py +24 -0
- venv/Lib/site-packages/pip/_vendor/requests/compat.py +67 -0
- venv/Lib/site-packages/pip/_vendor/requests/cookies.py +561 -0
- venv/Lib/site-packages/pip/_vendor/requests/exceptions.py +141 -0
- venv/Lib/site-packages/pip/_vendor/requests/help.py +131 -0
- venv/Lib/site-packages/pip/_vendor/requests/hooks.py +33 -0
- venv/Lib/site-packages/pip/_vendor/requests/models.py +1034 -0
- venv/Lib/site-packages/pip/_vendor/requests/packages.py +16 -0
- venv/Lib/site-packages/pip/_vendor/requests/sessions.py +833 -0
- venv/Lib/site-packages/pip/_vendor/requests/status_codes.py +128 -0
- venv/Lib/site-packages/pip/_vendor/requests/structures.py +99 -0
- venv/Lib/site-packages/pip/_vendor/requests/utils.py +1094 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/__init__.py +26 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/compat/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/compat/collections_abc.py +6 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/providers.py +133 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/reporters.py +43 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers.py +547 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/structs.py +170 -0
- venv/Lib/site-packages/pip/_vendor/rich/__init__.py +177 -0
- venv/Lib/site-packages/pip/_vendor/rich/__main__.py +274 -0
- venv/Lib/site-packages/pip/_vendor/rich/_cell_widths.py +451 -0
- venv/Lib/site-packages/pip/_vendor/rich/_emoji_codes.py +3610 -0
- venv/Lib/site-packages/pip/_vendor/rich/_emoji_replace.py +32 -0
- venv/Lib/site-packages/pip/_vendor/rich/_export_format.py +76 -0
- venv/Lib/site-packages/pip/_vendor/rich/_extension.py +10 -0
- venv/Lib/site-packages/pip/_vendor/rich/_fileno.py +24 -0
- venv/Lib/site-packages/pip/_vendor/rich/_inspect.py +270 -0
- venv/Lib/site-packages/pip/_vendor/rich/_log_render.py +94 -0
- venv/Lib/site-packages/pip/_vendor/rich/_loop.py +43 -0
- venv/Lib/site-packages/pip/_vendor/rich/_null_file.py +69 -0
- venv/Lib/site-packages/pip/_vendor/rich/_palettes.py +309 -0
- venv/Lib/site-packages/pip/_vendor/rich/_pick.py +17 -0
- venv/Lib/site-packages/pip/_vendor/rich/_ratio.py +160 -0
- venv/Lib/site-packages/pip/_vendor/rich/_spinners.py +482 -0
- venv/Lib/site-packages/pip/_vendor/rich/_stack.py +16 -0
- venv/Lib/site-packages/pip/_vendor/rich/_timer.py +19 -0
- venv/Lib/site-packages/pip/_vendor/rich/_win32_console.py +662 -0
- venv/Lib/site-packages/pip/_vendor/rich/_windows.py +72 -0
- venv/Lib/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
- venv/Lib/site-packages/pip/_vendor/rich/_wrap.py +56 -0
- venv/Lib/site-packages/pip/_vendor/rich/abc.py +33 -0
- venv/Lib/site-packages/pip/_vendor/rich/align.py +311 -0
- venv/Lib/site-packages/pip/_vendor/rich/ansi.py +240 -0
- venv/Lib/site-packages/pip/_vendor/rich/bar.py +94 -0
- venv/Lib/site-packages/pip/_vendor/rich/box.py +517 -0
- venv/Lib/site-packages/pip/_vendor/rich/cells.py +154 -0
- venv/Lib/site-packages/pip/_vendor/rich/color.py +622 -0
- venv/Lib/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
- venv/Lib/site-packages/pip/_vendor/rich/columns.py +187 -0
- venv/Lib/site-packages/pip/_vendor/rich/console.py +2633 -0
- venv/Lib/site-packages/pip/_vendor/rich/constrain.py +37 -0
- venv/Lib/site-packages/pip/_vendor/rich/containers.py +167 -0
- venv/Lib/site-packages/pip/_vendor/rich/control.py +225 -0
- venv/Lib/site-packages/pip/_vendor/rich/default_styles.py +190 -0
- venv/Lib/site-packages/pip/_vendor/rich/diagnose.py +37 -0
- venv/Lib/site-packages/pip/_vendor/rich/emoji.py +96 -0
- venv/Lib/site-packages/pip/_vendor/rich/errors.py +34 -0
- venv/Lib/site-packages/pip/_vendor/rich/file_proxy.py +57 -0
- venv/Lib/site-packages/pip/_vendor/rich/filesize.py +89 -0
- venv/Lib/site-packages/pip/_vendor/rich/highlighter.py +232 -0
- venv/Lib/site-packages/pip/_vendor/rich/json.py +140 -0
- venv/Lib/site-packages/pip/_vendor/rich/jupyter.py +101 -0
- venv/Lib/site-packages/pip/_vendor/rich/layout.py +443 -0
- venv/Lib/site-packages/pip/_vendor/rich/live.py +375 -0
- venv/Lib/site-packages/pip/_vendor/rich/live_render.py +113 -0
- venv/Lib/site-packages/pip/_vendor/rich/logging.py +289 -0
- venv/Lib/site-packages/pip/_vendor/rich/markup.py +246 -0
- venv/Lib/site-packages/pip/_vendor/rich/measure.py +151 -0
- venv/Lib/site-packages/pip/_vendor/rich/padding.py +141 -0
- venv/Lib/site-packages/pip/_vendor/rich/pager.py +34 -0
- venv/Lib/site-packages/pip/_vendor/rich/palette.py +100 -0
- venv/Lib/site-packages/pip/_vendor/rich/panel.py +308 -0
- venv/Lib/site-packages/pip/_vendor/rich/pretty.py +994 -0
- venv/Lib/site-packages/pip/_vendor/rich/progress.py +1702 -0
- venv/Lib/site-packages/pip/_vendor/rich/progress_bar.py +224 -0
- venv/Lib/site-packages/pip/_vendor/rich/prompt.py +376 -0
- venv/Lib/site-packages/pip/_vendor/rich/protocol.py +42 -0
- venv/Lib/site-packages/pip/_vendor/rich/region.py +10 -0
- venv/Lib/site-packages/pip/_vendor/rich/repr.py +149 -0
- venv/Lib/site-packages/pip/_vendor/rich/rule.py +130 -0
- venv/Lib/site-packages/pip/_vendor/rich/scope.py +86 -0
- venv/Lib/site-packages/pip/_vendor/rich/screen.py +54 -0
- venv/Lib/site-packages/pip/_vendor/rich/segment.py +739 -0
- venv/Lib/site-packages/pip/_vendor/rich/spinner.py +137 -0
- venv/Lib/site-packages/pip/_vendor/rich/status.py +132 -0
- venv/Lib/site-packages/pip/_vendor/rich/style.py +796 -0
- venv/Lib/site-packages/pip/_vendor/rich/styled.py +42 -0
- venv/Lib/site-packages/pip/_vendor/rich/syntax.py +948 -0
- venv/Lib/site-packages/pip/_vendor/rich/table.py +1002 -0
- venv/Lib/site-packages/pip/_vendor/rich/terminal_theme.py +153 -0
- venv/Lib/site-packages/pip/_vendor/rich/text.py +1307 -0
- venv/Lib/site-packages/pip/_vendor/rich/theme.py +115 -0
- venv/Lib/site-packages/pip/_vendor/rich/themes.py +5 -0
- venv/Lib/site-packages/pip/_vendor/rich/traceback.py +756 -0
- venv/Lib/site-packages/pip/_vendor/rich/tree.py +251 -0
- venv/Lib/site-packages/pip/_vendor/six.py +998 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/__init__.py +608 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/_asyncio.py +94 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/_utils.py +76 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/after.py +51 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/before.py +46 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/before_sleep.py +71 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/nap.py +43 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/retry.py +272 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/stop.py +103 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/tornadoweb.py +59 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/wait.py +228 -0
- venv/Lib/site-packages/pip/_vendor/tomli/__init__.py +11 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_parser.py +691 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_re.py +107 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_types.py +10 -0
- venv/Lib/site-packages/pip/_vendor/typing_extensions.py +3072 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/__init__.py +102 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/_collections.py +337 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/_version.py +2 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/connection.py +572 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py +1132 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py +36 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +519 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +397 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/appengine.py +314 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py +130 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +518 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +921 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/socks.py +216 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/exceptions.py +323 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/fields.py +274 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/filepost.py +98 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +51 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/weakref_finalize.py +155 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/six.py +1076 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/poolmanager.py +537 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/request.py +170 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/response.py +879 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/__init__.py +49 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/connection.py +149 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/proxy.py +57 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/queue.py +22 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/request.py +137 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/response.py +107 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/retry.py +620 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssl_.py +495 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +159 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssltransport.py +221 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/timeout.py +271 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/url.py +435 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/wait.py +152 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/__init__.py +342 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/labels.py +231 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/mklabels.py +59 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/tests.py +153 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/x_user_defined.py +325 -0
- venv/Lib/site-packages/pip/py.typed +4 -0
- venv/Lib/site-packages/pkg_resources/__init__.py +3296 -0
- venv/Lib/site-packages/pkg_resources/_vendor/__init__.py +0 -0
- venv/Lib/site-packages/pkg_resources/_vendor/appdirs.py +608 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/__init__.py +36 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_adapters.py +170 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_common.py +104 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_compat.py +98 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_itertools.py +35 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_legacy.py +121 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/abc.py +137 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/readers.py +122 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/simple.py +116 -0
- venv/Lib/site-packages/pkg_resources/_vendor/jaraco/__init__.py +0 -0
- venv/Lib/site-packages/pkg_resources/_vendor/jaraco/context.py +213 -0
- venv/Lib/site-packages/pkg_resources/_vendor/jaraco/functools.py +525 -0
- venv/Lib/site-packages/pkg_resources/_vendor/jaraco/text/__init__.py +599 -0
- venv/Lib/site-packages/pkg_resources/_vendor/more_itertools/__init__.py +4 -0
- venv/Lib/site-packages/pkg_resources/_vendor/more_itertools/more.py +4316 -0
- venv/Lib/site-packages/pkg_resources/_vendor/more_itertools/recipes.py +698 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/__about__.py +26 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/__init__.py +25 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/_manylinux.py +301 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/_musllinux.py +136 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/_structures.py +61 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/markers.py +304 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/requirements.py +146 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/specifiers.py +802 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/tags.py +487 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/utils.py +136 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/version.py +504 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/__init__.py +331 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/actions.py +207 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/common.py +424 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/core.py +5814 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/diagram/__init__.py +642 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/exceptions.py +267 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/helpers.py +1088 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/results.py +760 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/testing.py +331 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/unicode.py +352 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/util.py +235 -0
- venv/Lib/site-packages/pkg_resources/_vendor/zipp.py +329 -0
- venv/Lib/site-packages/pkg_resources/extern/__init__.py +76 -0
- venv/Lib/site-packages/setuptools/__init__.py +247 -0
- venv/Lib/site-packages/setuptools/_deprecation_warning.py +7 -0
- venv/Lib/site-packages/setuptools/_distutils/__init__.py +24 -0
- venv/Lib/site-packages/setuptools/_distutils/_collections.py +56 -0
- venv/Lib/site-packages/setuptools/_distutils/_functools.py +20 -0
- venv/Lib/site-packages/setuptools/_distutils/_macos_compat.py +12 -0
- venv/Lib/site-packages/setuptools/_distutils/_msvccompiler.py +572 -0
- venv/Lib/site-packages/setuptools/_distutils/archive_util.py +280 -0
- venv/Lib/site-packages/setuptools/_distutils/bcppcompiler.py +408 -0
- venv/Lib/site-packages/setuptools/_distutils/ccompiler.py +1220 -0
- venv/Lib/site-packages/setuptools/_distutils/cmd.py +436 -0
- venv/Lib/site-packages/setuptools/_distutils/command/__init__.py +25 -0
- venv/Lib/site-packages/setuptools/_distutils/command/_framework_compat.py +55 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist.py +157 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist_dumb.py +144 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist_rpm.py +615 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build.py +153 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_clib.py +208 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_ext.py +787 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_py.py +407 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +173 -0
- venv/Lib/site-packages/setuptools/_distutils/command/check.py +151 -0
- venv/Lib/site-packages/setuptools/_distutils/command/clean.py +76 -0
- venv/Lib/site-packages/setuptools/_distutils/command/config.py +377 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install.py +814 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_data.py +84 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_egg_info.py +91 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_headers.py +45 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_lib.py +238 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_scripts.py +61 -0
- venv/Lib/site-packages/setuptools/_distutils/command/py37compat.py +31 -0
- venv/Lib/site-packages/setuptools/_distutils/command/register.py +319 -0
- venv/Lib/site-packages/setuptools/_distutils/command/sdist.py +531 -0
- venv/Lib/site-packages/setuptools/_distutils/command/upload.py +205 -0
- venv/Lib/site-packages/setuptools/_distutils/config.py +139 -0
- venv/Lib/site-packages/setuptools/_distutils/core.py +291 -0
- venv/Lib/site-packages/setuptools/_distutils/cygwinccompiler.py +364 -0
- venv/Lib/site-packages/setuptools/_distutils/debug.py +5 -0
- venv/Lib/site-packages/setuptools/_distutils/dep_util.py +96 -0
- venv/Lib/site-packages/setuptools/_distutils/dir_util.py +243 -0
- venv/Lib/site-packages/setuptools/_distutils/dist.py +1286 -0
- venv/Lib/site-packages/setuptools/_distutils/errors.py +127 -0
- venv/Lib/site-packages/setuptools/_distutils/extension.py +248 -0
- venv/Lib/site-packages/setuptools/_distutils/fancy_getopt.py +470 -0
- venv/Lib/site-packages/setuptools/_distutils/file_util.py +249 -0
- venv/Lib/site-packages/setuptools/_distutils/filelist.py +371 -0
- venv/Lib/site-packages/setuptools/_distutils/log.py +80 -0
- venv/Lib/site-packages/setuptools/_distutils/msvc9compiler.py +832 -0
- venv/Lib/site-packages/setuptools/_distutils/msvccompiler.py +695 -0
- venv/Lib/site-packages/setuptools/_distutils/py38compat.py +8 -0
- venv/Lib/site-packages/setuptools/_distutils/py39compat.py +22 -0
- venv/Lib/site-packages/setuptools/_distutils/spawn.py +109 -0
- venv/Lib/site-packages/setuptools/_distutils/sysconfig.py +558 -0
- venv/Lib/site-packages/setuptools/_distutils/text_file.py +287 -0
- venv/Lib/site-packages/setuptools/_distutils/unixccompiler.py +401 -0
- venv/Lib/site-packages/setuptools/_distutils/util.py +513 -0
- venv/Lib/site-packages/setuptools/_distutils/version.py +358 -0
- venv/Lib/site-packages/setuptools/_distutils/versionpredicate.py +175 -0
- venv/Lib/site-packages/setuptools/_entry_points.py +86 -0
- venv/Lib/site-packages/setuptools/_imp.py +82 -0
- venv/Lib/site-packages/setuptools/_importlib.py +47 -0
- venv/Lib/site-packages/setuptools/_itertools.py +23 -0
- venv/Lib/site-packages/setuptools/_path.py +29 -0
- venv/Lib/site-packages/setuptools/_reqs.py +19 -0
- venv/Lib/site-packages/setuptools/_vendor/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/__init__.py +1047 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_adapters.py +68 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_collections.py +30 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_compat.py +71 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_functools.py +104 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_itertools.py +73 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_meta.py +48 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_text.py +99 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/__init__.py +36 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_adapters.py +170 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_common.py +104 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_compat.py +98 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_itertools.py +35 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_legacy.py +121 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/abc.py +137 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/readers.py +122 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/simple.py +116 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/context.py +213 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/functools.py +525 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/text/__init__.py +599 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/__init__.py +4 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/more.py +3824 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/recipes.py +620 -0
- venv/Lib/site-packages/setuptools/_vendor/ordered_set.py +488 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/__about__.py +26 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/__init__.py +25 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_manylinux.py +301 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_musllinux.py +136 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_structures.py +61 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/markers.py +304 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/requirements.py +146 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/specifiers.py +802 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/tags.py +487 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/utils.py +136 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/version.py +504 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/__init__.py +331 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/actions.py +207 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/common.py +424 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/core.py +5814 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/diagram/__init__.py +642 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/exceptions.py +267 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/helpers.py +1088 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/results.py +760 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/testing.py +331 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/unicode.py +352 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/util.py +235 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/__init__.py +11 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_parser.py +691 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_re.py +107 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_types.py +10 -0
- venv/Lib/site-packages/setuptools/_vendor/typing_extensions.py +2296 -0
- venv/Lib/site-packages/setuptools/_vendor/zipp.py +329 -0
- venv/Lib/site-packages/setuptools/archive_util.py +213 -0
- venv/Lib/site-packages/setuptools/build_meta.py +511 -0
- venv/Lib/site-packages/setuptools/command/__init__.py +12 -0
- venv/Lib/site-packages/setuptools/command/alias.py +78 -0
- venv/Lib/site-packages/setuptools/command/bdist_egg.py +457 -0
- venv/Lib/site-packages/setuptools/command/bdist_rpm.py +40 -0
- venv/Lib/site-packages/setuptools/command/build.py +146 -0
- venv/Lib/site-packages/setuptools/command/build_clib.py +101 -0
- venv/Lib/site-packages/setuptools/command/build_ext.py +383 -0
- venv/Lib/site-packages/setuptools/command/build_py.py +368 -0
- venv/Lib/site-packages/setuptools/command/develop.py +193 -0
- venv/Lib/site-packages/setuptools/command/dist_info.py +142 -0
- venv/Lib/site-packages/setuptools/command/easy_install.py +2312 -0
- venv/Lib/site-packages/setuptools/command/editable_wheel.py +844 -0
- venv/Lib/site-packages/setuptools/command/egg_info.py +763 -0
- venv/Lib/site-packages/setuptools/command/install.py +139 -0
- venv/Lib/site-packages/setuptools/command/install_egg_info.py +63 -0
- venv/Lib/site-packages/setuptools/command/install_lib.py +122 -0
- venv/Lib/site-packages/setuptools/command/install_scripts.py +70 -0
- venv/Lib/site-packages/setuptools/command/py36compat.py +134 -0
- venv/Lib/site-packages/setuptools/command/register.py +18 -0
- venv/Lib/site-packages/setuptools/command/rotate.py +64 -0
- venv/Lib/site-packages/setuptools/command/saveopts.py +22 -0
- venv/Lib/site-packages/setuptools/command/sdist.py +210 -0
- venv/Lib/site-packages/setuptools/command/setopt.py +149 -0
- venv/Lib/site-packages/setuptools/command/test.py +251 -0
- venv/Lib/site-packages/setuptools/command/upload.py +17 -0
- venv/Lib/site-packages/setuptools/command/upload_docs.py +213 -0
- venv/Lib/site-packages/setuptools/config/__init__.py +35 -0
- venv/Lib/site-packages/setuptools/config/_apply_pyprojecttoml.py +377 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/__init__.py +34 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/error_reporting.py +318 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/extra_validations.py +36 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py +51 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_validations.py +1035 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/formats.py +259 -0
- venv/Lib/site-packages/setuptools/config/expand.py +462 -0
- venv/Lib/site-packages/setuptools/config/pyprojecttoml.py +493 -0
- venv/Lib/site-packages/setuptools/config/setupcfg.py +762 -0
- venv/Lib/site-packages/setuptools/dep_util.py +25 -0
- venv/Lib/site-packages/setuptools/depends.py +176 -0
- venv/Lib/site-packages/setuptools/discovery.py +600 -0
- venv/Lib/site-packages/setuptools/dist.py +1222 -0
- venv/Lib/site-packages/setuptools/errors.py +58 -0
- venv/Lib/site-packages/setuptools/extension.py +148 -0
- venv/Lib/site-packages/setuptools/extern/__init__.py +76 -0
- venv/Lib/site-packages/setuptools/glob.py +167 -0
- venv/Lib/site-packages/setuptools/installer.py +104 -0
- venv/Lib/site-packages/setuptools/launch.py +36 -0
- venv/Lib/site-packages/setuptools/logging.py +36 -0
- venv/Lib/site-packages/setuptools/monkey.py +165 -0
- venv/Lib/site-packages/setuptools/msvc.py +1703 -0
- venv/Lib/site-packages/setuptools/namespaces.py +107 -0
- venv/Lib/site-packages/setuptools/package_index.py +1126 -0
- venv/Lib/site-packages/setuptools/py34compat.py +13 -0
- venv/Lib/site-packages/setuptools/sandbox.py +530 -0
- venv/Lib/site-packages/setuptools/unicode_utils.py +42 -0
- venv/Lib/site-packages/setuptools/version.py +6 -0
- venv/Lib/site-packages/setuptools/wheel.py +222 -0
- venv/Lib/site-packages/setuptools/windows_support.py +29 -0
- xplia/__init__.py +72 -0
- xplia/api/__init__.py +432 -0
- xplia/api/fastapi_app.py +453 -0
- xplia/cli.py +321 -0
- xplia/compliance/__init__.py +39 -0
- xplia/compliance/ai_act.py +538 -0
- xplia/compliance/compliance_checker.py +511 -0
- xplia/compliance/compliance_report.py +236 -0
- xplia/compliance/expert_review/__init__.py +18 -0
- xplia/compliance/expert_review/evaluation_criteria.py +209 -0
- xplia/compliance/expert_review/integration.py +270 -0
- xplia/compliance/expert_review/trust_expert_evaluator.py +379 -0
- xplia/compliance/explanation_rights.py +45 -0
- xplia/compliance/formatters/__init__.py +35 -0
- xplia/compliance/formatters/csv_formatter.py +179 -0
- xplia/compliance/formatters/html_formatter.py +689 -0
- xplia/compliance/formatters/html_trust_formatter.py +147 -0
- xplia/compliance/formatters/json_formatter.py +107 -0
- xplia/compliance/formatters/pdf_formatter.py +641 -0
- xplia/compliance/formatters/pdf_trust_formatter.py +309 -0
- xplia/compliance/formatters/trust_formatter_mixin.py +267 -0
- xplia/compliance/formatters/xml_formatter.py +173 -0
- xplia/compliance/gdpr.py +803 -0
- xplia/compliance/hipaa.py +134 -0
- xplia/compliance/report_base.py +205 -0
- xplia/compliance/report_generator.py +820 -0
- xplia/compliance/translations.py +299 -0
- xplia/core/__init__.py +98 -0
- xplia/core/base.py +391 -0
- xplia/core/config.py +297 -0
- xplia/core/factory.py +416 -0
- xplia/core/model_adapters/__init__.py +47 -0
- xplia/core/model_adapters/base.py +160 -0
- xplia/core/model_adapters/pytorch_adapter.py +339 -0
- xplia/core/model_adapters/sklearn_adapter.py +215 -0
- xplia/core/model_adapters/tensorflow_adapter.py +280 -0
- xplia/core/model_adapters/xgboost_adapter.py +295 -0
- xplia/core/optimizations.py +322 -0
- xplia/core/performance/__init__.py +57 -0
- xplia/core/performance/cache_manager.py +502 -0
- xplia/core/performance/memory_optimizer.py +465 -0
- xplia/core/performance/parallel_executor.py +327 -0
- xplia/core/registry.py +1234 -0
- xplia/explainers/__init__.py +70 -0
- xplia/explainers/__init__updated.py +62 -0
- xplia/explainers/adaptive/__init__.py +24 -0
- xplia/explainers/adaptive/explainer_selector.py +405 -0
- xplia/explainers/adaptive/explanation_quality.py +395 -0
- xplia/explainers/adaptive/fusion_strategies.py +297 -0
- xplia/explainers/adaptive/meta_explainer.py +320 -0
- xplia/explainers/adversarial/__init__.py +21 -0
- xplia/explainers/adversarial/adversarial_xai.py +678 -0
- xplia/explainers/anchor_explainer.py +1769 -0
- xplia/explainers/attention_explainer.py +996 -0
- xplia/explainers/bayesian/__init__.py +8 -0
- xplia/explainers/bayesian/bayesian_explainer.py +127 -0
- xplia/explainers/bias/__init__.py +17 -0
- xplia/explainers/bias/advanced_bias_detection.py +934 -0
- xplia/explainers/calibration/__init__.py +26 -0
- xplia/explainers/calibration/audience_adapter.py +376 -0
- xplia/explainers/calibration/audience_profiles.py +372 -0
- xplia/explainers/calibration/calibration_metrics.py +299 -0
- xplia/explainers/calibration/explanation_calibrator.py +460 -0
- xplia/explainers/causal/__init__.py +19 -0
- xplia/explainers/causal/causal_inference.py +669 -0
- xplia/explainers/certified/__init__.py +21 -0
- xplia/explainers/certified/certified_explanations.py +619 -0
- xplia/explainers/continual/__init__.py +8 -0
- xplia/explainers/continual/continual_explainer.py +102 -0
- xplia/explainers/counterfactual_explainer.py +804 -0
- xplia/explainers/counterfactuals/__init__.py +17 -0
- xplia/explainers/counterfactuals/advanced_counterfactuals.py +259 -0
- xplia/explainers/expert_evaluator.py +538 -0
- xplia/explainers/feature_importance_explainer.py +376 -0
- xplia/explainers/federated/__init__.py +17 -0
- xplia/explainers/federated/federated_xai.py +664 -0
- xplia/explainers/generative/__init__.py +15 -0
- xplia/explainers/generative/generative_explainer.py +243 -0
- xplia/explainers/gradient_explainer.py +3590 -0
- xplia/explainers/graph/__init__.py +26 -0
- xplia/explainers/graph/gnn_explainer.py +638 -0
- xplia/explainers/graph/molecular_explainer.py +438 -0
- xplia/explainers/lime_explainer.py +1580 -0
- xplia/explainers/llm/__init__.py +23 -0
- xplia/explainers/llm/llm_explainability.py +737 -0
- xplia/explainers/metalearning/__init__.py +15 -0
- xplia/explainers/metalearning/metalearning_explainer.py +276 -0
- xplia/explainers/moe/__init__.py +8 -0
- xplia/explainers/moe/moe_explainer.py +108 -0
- xplia/explainers/multimodal/__init__.py +30 -0
- xplia/explainers/multimodal/base.py +262 -0
- xplia/explainers/multimodal/diffusion_explainer.py +608 -0
- xplia/explainers/multimodal/foundation_model_explainer.py +323 -0
- xplia/explainers/multimodal/registry.py +139 -0
- xplia/explainers/multimodal/text_image_explainer.py +381 -0
- xplia/explainers/multimodal/vision_language_explainer.py +608 -0
- xplia/explainers/nas/__init__.py +5 -0
- xplia/explainers/nas/nas_explainer.py +65 -0
- xplia/explainers/neuralodes/__init__.py +5 -0
- xplia/explainers/neuralodes/neuralode_explainer.py +64 -0
- xplia/explainers/neurosymbolic/__init__.py +8 -0
- xplia/explainers/neurosymbolic/neurosymbolic_explainer.py +97 -0
- xplia/explainers/partial_dependence_explainer.py +509 -0
- xplia/explainers/privacy/__init__.py +21 -0
- xplia/explainers/privacy/differential_privacy_xai.py +624 -0
- xplia/explainers/quantum/__init__.py +5 -0
- xplia/explainers/quantum/quantum_explainer.py +79 -0
- xplia/explainers/recommender/__init__.py +8 -0
- xplia/explainers/recommender/recsys_explainer.py +124 -0
- xplia/explainers/reinforcement/__init__.py +15 -0
- xplia/explainers/reinforcement/rl_explainer.py +173 -0
- xplia/explainers/shap_explainer.py +2238 -0
- xplia/explainers/streaming/__init__.py +19 -0
- xplia/explainers/streaming/streaming_xai.py +703 -0
- xplia/explainers/timeseries/__init__.py +15 -0
- xplia/explainers/timeseries/timeseries_explainer.py +252 -0
- xplia/explainers/trust/__init__.py +24 -0
- xplia/explainers/trust/confidence_report.py +368 -0
- xplia/explainers/trust/fairwashing.py +489 -0
- xplia/explainers/trust/uncertainty.py +453 -0
- xplia/explainers/unified_explainer.py +566 -0
- xplia/explainers/unified_explainer_utils.py +309 -0
- xplia/integrations/__init__.py +3 -0
- xplia/integrations/mlflow_integration.py +331 -0
- xplia/integrations/wandb_integration.py +375 -0
- xplia/plugins/__init__.py +36 -0
- xplia/plugins/example_visualizer.py +11 -0
- xplia/utils/__init__.py +18 -0
- xplia/utils/performance.py +119 -0
- xplia/utils/validation.py +109 -0
- xplia/visualizations/__init__.py +31 -0
- xplia/visualizations/base.py +256 -0
- xplia/visualizations/boxplot_chart.py +224 -0
- xplia/visualizations/charts_impl.py +65 -0
- xplia/visualizations/gauge_chart.py +211 -0
- xplia/visualizations/gradient_viz.py +117 -0
- xplia/visualizations/heatmap_chart.py +173 -0
- xplia/visualizations/histogram_chart.py +176 -0
- xplia/visualizations/line_chart.py +100 -0
- xplia/visualizations/pie_chart.py +134 -0
- xplia/visualizations/radar_chart.py +154 -0
- xplia/visualizations/registry.py +76 -0
- xplia/visualizations/sankey_chart.py +190 -0
- xplia/visualizations/scatter_chart.py +252 -0
- xplia/visualizations/table_chart.py +263 -0
- xplia/visualizations/treemap_chart.py +216 -0
- xplia/visualizations.py +535 -0
- xplia/visualizers/__init__.py +87 -0
- xplia/visualizers/base_visualizer.py +294 -0
- xplia-1.0.1.dist-info/METADATA +685 -0
- xplia-1.0.1.dist-info/RECORD +870 -0
- xplia-1.0.1.dist-info/WHEEL +5 -0
- xplia-1.0.1.dist-info/entry_points.txt +2 -0
- xplia-1.0.1.dist-info/licenses/LICENSE +21 -0
- xplia-1.0.1.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,934 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Advanced Bias Detection System.
|
|
3
|
+
|
|
4
|
+
Multi-level bias detection across data, model, explanations, and outcomes.
|
|
5
|
+
|
|
6
|
+
Author: XPLIA Team
|
|
7
|
+
License: MIT
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
from typing import Dict, Any, Optional, List, Tuple
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
import warnings
|
|
14
|
+
|
|
15
|
+
from xplia.core.base import ExplanationResult
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class BiasReport:
|
|
20
|
+
"""
|
|
21
|
+
Comprehensive bias report.
|
|
22
|
+
|
|
23
|
+
Attributes
|
|
24
|
+
----------
|
|
25
|
+
bias_detected : bool
|
|
26
|
+
Whether bias was detected.
|
|
27
|
+
bias_level : str
|
|
28
|
+
'low', 'medium', 'high'.
|
|
29
|
+
bias_types : list of str
|
|
30
|
+
Types of bias detected.
|
|
31
|
+
bias_scores : dict
|
|
32
|
+
Bias scores for each type.
|
|
33
|
+
protected_attributes : list of str
|
|
34
|
+
Protected attributes analyzed.
|
|
35
|
+
recommendations : list of str
|
|
36
|
+
Mitigation recommendations.
|
|
37
|
+
metadata : dict
|
|
38
|
+
Additional metadata.
|
|
39
|
+
"""
|
|
40
|
+
bias_detected: bool
|
|
41
|
+
bias_level: str
|
|
42
|
+
bias_types: List[str]
|
|
43
|
+
bias_scores: Dict[str, float]
|
|
44
|
+
protected_attributes: List[str]
|
|
45
|
+
recommendations: List[str]
|
|
46
|
+
metadata: Dict[str, Any]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class DataBiasDetector:
|
|
50
|
+
"""
|
|
51
|
+
Detect bias in training/test data.
|
|
52
|
+
|
|
53
|
+
Analyzes data distribution for representation bias, label bias,
|
|
54
|
+
and correlation with protected attributes.
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
protected_attributes : list of str
|
|
59
|
+
Names of protected attributes (e.g., ['gender', 'race']).
|
|
60
|
+
threshold : float
|
|
61
|
+
Bias detection threshold.
|
|
62
|
+
|
|
63
|
+
Examples
|
|
64
|
+
--------
|
|
65
|
+
>>> detector = DataBiasDetector(protected_attributes=['gender'])
|
|
66
|
+
>>> bias_report = detector.detect(X, y, protected_attr_data)
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def __init__(
|
|
70
|
+
self,
|
|
71
|
+
protected_attributes: List[str],
|
|
72
|
+
threshold: float = 0.1
|
|
73
|
+
):
|
|
74
|
+
self.protected_attributes = protected_attributes
|
|
75
|
+
self.threshold = threshold
|
|
76
|
+
|
|
77
|
+
def detect_representation_bias(
|
|
78
|
+
self,
|
|
79
|
+
protected_data: np.ndarray
|
|
80
|
+
) -> Tuple[bool, float]:
|
|
81
|
+
"""
|
|
82
|
+
Detect representation bias.
|
|
83
|
+
|
|
84
|
+
Checks if protected groups are under/over-represented.
|
|
85
|
+
|
|
86
|
+
Parameters
|
|
87
|
+
----------
|
|
88
|
+
protected_data : ndarray
|
|
89
|
+
Protected attribute values.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
biased : bool
|
|
94
|
+
True if representation bias detected.
|
|
95
|
+
score : float
|
|
96
|
+
Bias score (0 = balanced, 1 = maximum imbalance).
|
|
97
|
+
"""
|
|
98
|
+
unique, counts = np.unique(protected_data, return_counts=True)
|
|
99
|
+
|
|
100
|
+
if len(unique) < 2:
|
|
101
|
+
return False, 0.0
|
|
102
|
+
|
|
103
|
+
# Compute imbalance ratio
|
|
104
|
+
max_count = np.max(counts)
|
|
105
|
+
min_count = np.min(counts)
|
|
106
|
+
imbalance_ratio = 1.0 - (min_count / max_count)
|
|
107
|
+
|
|
108
|
+
biased = imbalance_ratio > self.threshold
|
|
109
|
+
|
|
110
|
+
return biased, float(imbalance_ratio)
|
|
111
|
+
|
|
112
|
+
def detect_label_bias(
|
|
113
|
+
self,
|
|
114
|
+
y: np.ndarray,
|
|
115
|
+
protected_data: np.ndarray
|
|
116
|
+
) -> Tuple[bool, float]:
|
|
117
|
+
"""
|
|
118
|
+
Detect label bias.
|
|
119
|
+
|
|
120
|
+
Checks if labels are correlated with protected attributes.
|
|
121
|
+
|
|
122
|
+
Parameters
|
|
123
|
+
----------
|
|
124
|
+
y : ndarray
|
|
125
|
+
Labels.
|
|
126
|
+
protected_data : ndarray
|
|
127
|
+
Protected attribute values.
|
|
128
|
+
|
|
129
|
+
Returns
|
|
130
|
+
-------
|
|
131
|
+
biased : bool
|
|
132
|
+
True if label bias detected.
|
|
133
|
+
score : float
|
|
134
|
+
Correlation strength.
|
|
135
|
+
"""
|
|
136
|
+
# Compute correlation
|
|
137
|
+
if protected_data.dtype == object or len(np.unique(protected_data)) < 10:
|
|
138
|
+
# Categorical protected attribute
|
|
139
|
+
# Use chi-square or similar
|
|
140
|
+
# For demo: simplified correlation
|
|
141
|
+
unique_groups = np.unique(protected_data)
|
|
142
|
+
|
|
143
|
+
if len(unique_groups) < 2:
|
|
144
|
+
return False, 0.0
|
|
145
|
+
|
|
146
|
+
# Compare label rates across groups
|
|
147
|
+
label_rates = []
|
|
148
|
+
for group in unique_groups:
|
|
149
|
+
mask = protected_data == group
|
|
150
|
+
if np.sum(mask) > 0:
|
|
151
|
+
label_rate = np.mean(y[mask])
|
|
152
|
+
label_rates.append(label_rate)
|
|
153
|
+
|
|
154
|
+
if len(label_rates) < 2:
|
|
155
|
+
return False, 0.0
|
|
156
|
+
|
|
157
|
+
# Measure disparity
|
|
158
|
+
max_rate = np.max(label_rates)
|
|
159
|
+
min_rate = np.min(label_rates)
|
|
160
|
+
disparity = max_rate - min_rate
|
|
161
|
+
|
|
162
|
+
biased = disparity > self.threshold
|
|
163
|
+
|
|
164
|
+
return biased, float(disparity)
|
|
165
|
+
else:
|
|
166
|
+
# Continuous protected attribute
|
|
167
|
+
correlation = np.abs(np.corrcoef(y, protected_data)[0, 1])
|
|
168
|
+
biased = correlation > self.threshold
|
|
169
|
+
|
|
170
|
+
return biased, float(correlation)
|
|
171
|
+
|
|
172
|
+
def detect(
|
|
173
|
+
self,
|
|
174
|
+
X: np.ndarray,
|
|
175
|
+
y: np.ndarray,
|
|
176
|
+
protected_data: Dict[str, np.ndarray]
|
|
177
|
+
) -> BiasReport:
|
|
178
|
+
"""
|
|
179
|
+
Comprehensive data bias detection.
|
|
180
|
+
|
|
181
|
+
Parameters
|
|
182
|
+
----------
|
|
183
|
+
X : ndarray
|
|
184
|
+
Features.
|
|
185
|
+
y : ndarray
|
|
186
|
+
Labels.
|
|
187
|
+
protected_data : dict
|
|
188
|
+
Dictionary mapping attribute names to values.
|
|
189
|
+
|
|
190
|
+
Returns
|
|
191
|
+
-------
|
|
192
|
+
report : BiasReport
|
|
193
|
+
Data bias report.
|
|
194
|
+
"""
|
|
195
|
+
bias_types = []
|
|
196
|
+
bias_scores = {}
|
|
197
|
+
recommendations = []
|
|
198
|
+
|
|
199
|
+
# Check each protected attribute
|
|
200
|
+
for attr_name, attr_values in protected_data.items():
|
|
201
|
+
# Representation bias
|
|
202
|
+
repr_biased, repr_score = self.detect_representation_bias(attr_values)
|
|
203
|
+
bias_scores[f'{attr_name}_representation'] = repr_score
|
|
204
|
+
|
|
205
|
+
if repr_biased:
|
|
206
|
+
bias_types.append(f'{attr_name}_representation_bias')
|
|
207
|
+
recommendations.append(
|
|
208
|
+
f"Collect more data for underrepresented {attr_name} groups"
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
# Label bias
|
|
212
|
+
label_biased, label_score = self.detect_label_bias(y, attr_values)
|
|
213
|
+
bias_scores[f'{attr_name}_label'] = label_score
|
|
214
|
+
|
|
215
|
+
if label_biased:
|
|
216
|
+
bias_types.append(f'{attr_name}_label_bias')
|
|
217
|
+
recommendations.append(
|
|
218
|
+
f"Investigate causal relationship between {attr_name} and labels"
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
# Overall assessment
|
|
222
|
+
bias_detected = len(bias_types) > 0
|
|
223
|
+
|
|
224
|
+
if bias_detected:
|
|
225
|
+
avg_score = np.mean(list(bias_scores.values()))
|
|
226
|
+
if avg_score > 0.3:
|
|
227
|
+
bias_level = 'high'
|
|
228
|
+
elif avg_score > 0.15:
|
|
229
|
+
bias_level = 'medium'
|
|
230
|
+
else:
|
|
231
|
+
bias_level = 'low'
|
|
232
|
+
else:
|
|
233
|
+
bias_level = 'none'
|
|
234
|
+
|
|
235
|
+
return BiasReport(
|
|
236
|
+
bias_detected=bias_detected,
|
|
237
|
+
bias_level=bias_level,
|
|
238
|
+
bias_types=bias_types,
|
|
239
|
+
bias_scores=bias_scores,
|
|
240
|
+
protected_attributes=list(protected_data.keys()),
|
|
241
|
+
recommendations=recommendations,
|
|
242
|
+
metadata={'data_size': X.shape[0]}
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class ModelBiasDetector:
|
|
247
|
+
"""
|
|
248
|
+
Detect bias in model predictions.
|
|
249
|
+
|
|
250
|
+
Analyzes model for disparate impact, equalized odds violations,
|
|
251
|
+
and demographic parity.
|
|
252
|
+
|
|
253
|
+
Parameters
|
|
254
|
+
----------
|
|
255
|
+
protected_attributes : list of str
|
|
256
|
+
Protected attribute names.
|
|
257
|
+
fairness_threshold : float
|
|
258
|
+
Threshold for fairness metrics.
|
|
259
|
+
|
|
260
|
+
Examples
|
|
261
|
+
--------
|
|
262
|
+
>>> detector = ModelBiasDetector(protected_attributes=['gender'])
|
|
263
|
+
>>> bias_report = detector.detect(model, X_test, y_test, protected_test)
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
def __init__(
|
|
267
|
+
self,
|
|
268
|
+
protected_attributes: List[str],
|
|
269
|
+
fairness_threshold: float = 0.8
|
|
270
|
+
):
|
|
271
|
+
self.protected_attributes = protected_attributes
|
|
272
|
+
self.fairness_threshold = fairness_threshold
|
|
273
|
+
|
|
274
|
+
def compute_disparate_impact(
|
|
275
|
+
self,
|
|
276
|
+
y_pred: np.ndarray,
|
|
277
|
+
protected_data: np.ndarray
|
|
278
|
+
) -> float:
|
|
279
|
+
"""
|
|
280
|
+
Compute disparate impact ratio.
|
|
281
|
+
|
|
282
|
+
DI = (positive rate for unprivileged) / (positive rate for privileged)
|
|
283
|
+
Fair if 0.8 <= DI <= 1.25
|
|
284
|
+
|
|
285
|
+
Parameters
|
|
286
|
+
----------
|
|
287
|
+
y_pred : ndarray
|
|
288
|
+
Predictions.
|
|
289
|
+
protected_data : ndarray
|
|
290
|
+
Protected attribute values.
|
|
291
|
+
|
|
292
|
+
Returns
|
|
293
|
+
-------
|
|
294
|
+
disparate_impact : float
|
|
295
|
+
Disparate impact ratio.
|
|
296
|
+
"""
|
|
297
|
+
unique_groups = np.unique(protected_data)
|
|
298
|
+
|
|
299
|
+
if len(unique_groups) < 2:
|
|
300
|
+
return 1.0
|
|
301
|
+
|
|
302
|
+
# Compute positive rates
|
|
303
|
+
positive_rates = []
|
|
304
|
+
for group in unique_groups:
|
|
305
|
+
mask = protected_data == group
|
|
306
|
+
if np.sum(mask) > 0:
|
|
307
|
+
pos_rate = np.mean(y_pred[mask])
|
|
308
|
+
positive_rates.append(pos_rate)
|
|
309
|
+
|
|
310
|
+
if len(positive_rates) < 2:
|
|
311
|
+
return 1.0
|
|
312
|
+
|
|
313
|
+
# DI = min / max
|
|
314
|
+
disparate_impact = np.min(positive_rates) / (np.max(positive_rates) + 1e-8)
|
|
315
|
+
|
|
316
|
+
return float(disparate_impact)
|
|
317
|
+
|
|
318
|
+
def compute_equalized_odds(
|
|
319
|
+
self,
|
|
320
|
+
y_true: np.ndarray,
|
|
321
|
+
y_pred: np.ndarray,
|
|
322
|
+
protected_data: np.ndarray
|
|
323
|
+
) -> Tuple[float, float]:
|
|
324
|
+
"""
|
|
325
|
+
Compute equalized odds violation.
|
|
326
|
+
|
|
327
|
+
Measures difference in TPR and FPR across groups.
|
|
328
|
+
|
|
329
|
+
Parameters
|
|
330
|
+
----------
|
|
331
|
+
y_true : ndarray
|
|
332
|
+
True labels.
|
|
333
|
+
y_pred : ndarray
|
|
334
|
+
Predictions.
|
|
335
|
+
protected_data : ndarray
|
|
336
|
+
Protected attribute values.
|
|
337
|
+
|
|
338
|
+
Returns
|
|
339
|
+
-------
|
|
340
|
+
tpr_diff : float
|
|
341
|
+
Difference in true positive rates.
|
|
342
|
+
fpr_diff : float
|
|
343
|
+
Difference in false positive rates.
|
|
344
|
+
"""
|
|
345
|
+
unique_groups = np.unique(protected_data)
|
|
346
|
+
|
|
347
|
+
if len(unique_groups) < 2:
|
|
348
|
+
return 0.0, 0.0
|
|
349
|
+
|
|
350
|
+
tprs = []
|
|
351
|
+
fprs = []
|
|
352
|
+
|
|
353
|
+
for group in unique_groups:
|
|
354
|
+
mask = protected_data == group
|
|
355
|
+
|
|
356
|
+
if np.sum(mask) == 0:
|
|
357
|
+
continue
|
|
358
|
+
|
|
359
|
+
y_true_group = y_true[mask]
|
|
360
|
+
y_pred_group = y_pred[mask]
|
|
361
|
+
|
|
362
|
+
# TPR
|
|
363
|
+
true_positives = np.sum((y_true_group == 1) & (y_pred_group == 1))
|
|
364
|
+
condition_positive = np.sum(y_true_group == 1)
|
|
365
|
+
tpr = true_positives / (condition_positive + 1e-8)
|
|
366
|
+
tprs.append(tpr)
|
|
367
|
+
|
|
368
|
+
# FPR
|
|
369
|
+
false_positives = np.sum((y_true_group == 0) & (y_pred_group == 1))
|
|
370
|
+
condition_negative = np.sum(y_true_group == 0)
|
|
371
|
+
fpr = false_positives / (condition_negative + 1e-8)
|
|
372
|
+
fprs.append(fpr)
|
|
373
|
+
|
|
374
|
+
if len(tprs) < 2 or len(fprs) < 2:
|
|
375
|
+
return 0.0, 0.0
|
|
376
|
+
|
|
377
|
+
tpr_diff = np.max(tprs) - np.min(tprs)
|
|
378
|
+
fpr_diff = np.max(fprs) - np.min(fprs)
|
|
379
|
+
|
|
380
|
+
return float(tpr_diff), float(fpr_diff)
|
|
381
|
+
|
|
382
|
+
def detect(
|
|
383
|
+
self,
|
|
384
|
+
model: Any,
|
|
385
|
+
X: np.ndarray,
|
|
386
|
+
y_true: np.ndarray,
|
|
387
|
+
protected_data: Dict[str, np.ndarray]
|
|
388
|
+
) -> BiasReport:
|
|
389
|
+
"""
|
|
390
|
+
Comprehensive model bias detection.
|
|
391
|
+
|
|
392
|
+
Parameters
|
|
393
|
+
----------
|
|
394
|
+
model : object
|
|
395
|
+
Trained model.
|
|
396
|
+
X : ndarray
|
|
397
|
+
Test features.
|
|
398
|
+
y_true : ndarray
|
|
399
|
+
True labels.
|
|
400
|
+
protected_data : dict
|
|
401
|
+
Protected attributes.
|
|
402
|
+
|
|
403
|
+
Returns
|
|
404
|
+
-------
|
|
405
|
+
report : BiasReport
|
|
406
|
+
Model bias report.
|
|
407
|
+
"""
|
|
408
|
+
# Get predictions
|
|
409
|
+
y_pred = model.predict(X)
|
|
410
|
+
|
|
411
|
+
bias_types = []
|
|
412
|
+
bias_scores = {}
|
|
413
|
+
recommendations = []
|
|
414
|
+
|
|
415
|
+
# Check each protected attribute
|
|
416
|
+
for attr_name, attr_values in protected_data.items():
|
|
417
|
+
# Disparate impact
|
|
418
|
+
di = self.compute_disparate_impact(y_pred, attr_values)
|
|
419
|
+
bias_scores[f'{attr_name}_disparate_impact'] = di
|
|
420
|
+
|
|
421
|
+
if di < self.fairness_threshold:
|
|
422
|
+
bias_types.append(f'{attr_name}_disparate_impact')
|
|
423
|
+
recommendations.append(
|
|
424
|
+
f"Apply fairness constraints or reweighing for {attr_name}"
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
# Equalized odds
|
|
428
|
+
tpr_diff, fpr_diff = self.compute_equalized_odds(y_true, y_pred, attr_values)
|
|
429
|
+
bias_scores[f'{attr_name}_tpr_diff'] = tpr_diff
|
|
430
|
+
bias_scores[f'{attr_name}_fpr_diff'] = fpr_diff
|
|
431
|
+
|
|
432
|
+
if tpr_diff > 0.1 or fpr_diff > 0.1:
|
|
433
|
+
bias_types.append(f'{attr_name}_equalized_odds_violation')
|
|
434
|
+
recommendations.append(
|
|
435
|
+
f"Use post-processing to equalize error rates across {attr_name} groups"
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
# Overall assessment
|
|
439
|
+
bias_detected = len(bias_types) > 0
|
|
440
|
+
|
|
441
|
+
if bias_detected:
|
|
442
|
+
# Assess severity
|
|
443
|
+
di_values = [v for k, v in bias_scores.items() if 'disparate_impact' in k]
|
|
444
|
+
worst_di = np.min(di_values) if di_values else 1.0
|
|
445
|
+
|
|
446
|
+
if worst_di < 0.6:
|
|
447
|
+
bias_level = 'high'
|
|
448
|
+
elif worst_di < 0.75:
|
|
449
|
+
bias_level = 'medium'
|
|
450
|
+
else:
|
|
451
|
+
bias_level = 'low'
|
|
452
|
+
else:
|
|
453
|
+
bias_level = 'none'
|
|
454
|
+
|
|
455
|
+
return BiasReport(
|
|
456
|
+
bias_detected=bias_detected,
|
|
457
|
+
bias_level=bias_level,
|
|
458
|
+
bias_types=bias_types,
|
|
459
|
+
bias_scores=bias_scores,
|
|
460
|
+
protected_attributes=list(protected_data.keys()),
|
|
461
|
+
recommendations=recommendations,
|
|
462
|
+
metadata={'n_predictions': len(y_pred)}
|
|
463
|
+
)
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
class ExplanationBiasDetector:
|
|
467
|
+
"""
|
|
468
|
+
Detect bias in explanations.
|
|
469
|
+
|
|
470
|
+
Checks if explanations unfairly attribute importance to protected
|
|
471
|
+
attributes or show different patterns across groups.
|
|
472
|
+
|
|
473
|
+
Parameters
|
|
474
|
+
----------
|
|
475
|
+
protected_attributes : list of str
|
|
476
|
+
Protected attribute names.
|
|
477
|
+
threshold : float
|
|
478
|
+
Bias threshold.
|
|
479
|
+
|
|
480
|
+
Examples
|
|
481
|
+
--------
|
|
482
|
+
>>> detector = ExplanationBiasDetector(protected_attributes=['gender'])
|
|
483
|
+
>>> bias_report = detector.detect(explanations, protected_data)
|
|
484
|
+
"""
|
|
485
|
+
|
|
486
|
+
def __init__(
|
|
487
|
+
self,
|
|
488
|
+
protected_attributes: List[str],
|
|
489
|
+
threshold: float = 0.1
|
|
490
|
+
):
|
|
491
|
+
self.protected_attributes = protected_attributes
|
|
492
|
+
self.threshold = threshold
|
|
493
|
+
|
|
494
|
+
def detect_protected_attribute_importance(
|
|
495
|
+
self,
|
|
496
|
+
explanations: List[ExplanationResult],
|
|
497
|
+
protected_attr_indices: List[int]
|
|
498
|
+
) -> Tuple[bool, float]:
|
|
499
|
+
"""
|
|
500
|
+
Check if protected attributes have high importance.
|
|
501
|
+
|
|
502
|
+
Parameters
|
|
503
|
+
----------
|
|
504
|
+
explanations : list of ExplanationResult
|
|
505
|
+
Explanations to check.
|
|
506
|
+
protected_attr_indices : list of int
|
|
507
|
+
Indices of protected attributes in feature vector.
|
|
508
|
+
|
|
509
|
+
Returns
|
|
510
|
+
-------
|
|
511
|
+
biased : bool
|
|
512
|
+
True if protected attributes are important.
|
|
513
|
+
score : float
|
|
514
|
+
Average importance of protected attributes.
|
|
515
|
+
"""
|
|
516
|
+
protected_importances = []
|
|
517
|
+
|
|
518
|
+
for exp in explanations:
|
|
519
|
+
if 'feature_importance' not in exp.explanation_data:
|
|
520
|
+
continue
|
|
521
|
+
|
|
522
|
+
importance = np.array(exp.explanation_data['feature_importance'])
|
|
523
|
+
|
|
524
|
+
# Get importance of protected attributes
|
|
525
|
+
protected_imp = np.abs(importance[protected_attr_indices])
|
|
526
|
+
protected_importances.append(np.mean(protected_imp))
|
|
527
|
+
|
|
528
|
+
if not protected_importances:
|
|
529
|
+
return False, 0.0
|
|
530
|
+
|
|
531
|
+
avg_protected_importance = np.mean(protected_importances)
|
|
532
|
+
biased = avg_protected_importance > self.threshold
|
|
533
|
+
|
|
534
|
+
return biased, float(avg_protected_importance)
|
|
535
|
+
|
|
536
|
+
def detect_explanation_disparity(
|
|
537
|
+
self,
|
|
538
|
+
explanations: List[ExplanationResult],
|
|
539
|
+
protected_data: np.ndarray
|
|
540
|
+
) -> Tuple[bool, float]:
|
|
541
|
+
"""
|
|
542
|
+
Check if explanations differ significantly across groups.
|
|
543
|
+
|
|
544
|
+
Parameters
|
|
545
|
+
----------
|
|
546
|
+
explanations : list of ExplanationResult
|
|
547
|
+
Explanations.
|
|
548
|
+
protected_data : ndarray
|
|
549
|
+
Protected attribute values.
|
|
550
|
+
|
|
551
|
+
Returns
|
|
552
|
+
-------
|
|
553
|
+
biased : bool
|
|
554
|
+
True if explanation disparity detected.
|
|
555
|
+
score : float
|
|
556
|
+
Disparity score.
|
|
557
|
+
"""
|
|
558
|
+
unique_groups = np.unique(protected_data)
|
|
559
|
+
|
|
560
|
+
if len(unique_groups) < 2:
|
|
561
|
+
return False, 0.0
|
|
562
|
+
|
|
563
|
+
# Group explanations by protected attribute
|
|
564
|
+
group_importances = {group: [] for group in unique_groups}
|
|
565
|
+
|
|
566
|
+
for i, exp in enumerate(explanations):
|
|
567
|
+
if 'feature_importance' not in exp.explanation_data:
|
|
568
|
+
continue
|
|
569
|
+
|
|
570
|
+
importance = np.array(exp.explanation_data['feature_importance'])
|
|
571
|
+
group = protected_data[i]
|
|
572
|
+
group_importances[group].append(importance)
|
|
573
|
+
|
|
574
|
+
# Compute average importance per group
|
|
575
|
+
avg_importances = []
|
|
576
|
+
for group in unique_groups:
|
|
577
|
+
if group_importances[group]:
|
|
578
|
+
avg_imp = np.mean(group_importances[group], axis=0)
|
|
579
|
+
avg_importances.append(avg_imp)
|
|
580
|
+
|
|
581
|
+
if len(avg_importances) < 2:
|
|
582
|
+
return False, 0.0
|
|
583
|
+
|
|
584
|
+
# Measure disparity (L2 distance between group averages)
|
|
585
|
+
disparities = []
|
|
586
|
+
for i in range(len(avg_importances)):
|
|
587
|
+
for j in range(i + 1, len(avg_importances)):
|
|
588
|
+
dist = np.linalg.norm(avg_importances[i] - avg_importances[j])
|
|
589
|
+
disparities.append(dist)
|
|
590
|
+
|
|
591
|
+
avg_disparity = np.mean(disparities)
|
|
592
|
+
biased = avg_disparity > self.threshold
|
|
593
|
+
|
|
594
|
+
return biased, float(avg_disparity)
|
|
595
|
+
|
|
596
|
+
def detect(
|
|
597
|
+
self,
|
|
598
|
+
explanations: List[ExplanationResult],
|
|
599
|
+
protected_data: Dict[str, np.ndarray],
|
|
600
|
+
protected_attr_indices: Optional[Dict[str, List[int]]] = None
|
|
601
|
+
) -> BiasReport:
|
|
602
|
+
"""
|
|
603
|
+
Comprehensive explanation bias detection.
|
|
604
|
+
|
|
605
|
+
Parameters
|
|
606
|
+
----------
|
|
607
|
+
explanations : list of ExplanationResult
|
|
608
|
+
Explanations to analyze.
|
|
609
|
+
protected_data : dict
|
|
610
|
+
Protected attributes.
|
|
611
|
+
protected_attr_indices : dict, optional
|
|
612
|
+
Indices of protected attributes in features.
|
|
613
|
+
|
|
614
|
+
Returns
|
|
615
|
+
-------
|
|
616
|
+
report : BiasReport
|
|
617
|
+
Explanation bias report.
|
|
618
|
+
"""
|
|
619
|
+
bias_types = []
|
|
620
|
+
bias_scores = {}
|
|
621
|
+
recommendations = []
|
|
622
|
+
|
|
623
|
+
protected_attr_indices = protected_attr_indices or {}
|
|
624
|
+
|
|
625
|
+
# Check each protected attribute
|
|
626
|
+
for attr_name, attr_values in protected_data.items():
|
|
627
|
+
# Check if protected attribute is important
|
|
628
|
+
if attr_name in protected_attr_indices:
|
|
629
|
+
biased, score = self.detect_protected_attribute_importance(
|
|
630
|
+
explanations,
|
|
631
|
+
protected_attr_indices[attr_name]
|
|
632
|
+
)
|
|
633
|
+
bias_scores[f'{attr_name}_importance'] = score
|
|
634
|
+
|
|
635
|
+
if biased:
|
|
636
|
+
bias_types.append(f'{attr_name}_high_importance')
|
|
637
|
+
recommendations.append(
|
|
638
|
+
f"Remove {attr_name} from model features or apply fairness constraints"
|
|
639
|
+
)
|
|
640
|
+
|
|
641
|
+
# Check explanation disparity
|
|
642
|
+
biased, score = self.detect_explanation_disparity(explanations, attr_values)
|
|
643
|
+
bias_scores[f'{attr_name}_disparity'] = score
|
|
644
|
+
|
|
645
|
+
if biased:
|
|
646
|
+
bias_types.append(f'{attr_name}_explanation_disparity')
|
|
647
|
+
recommendations.append(
|
|
648
|
+
f"Investigate why explanations differ across {attr_name} groups"
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
# Overall assessment
|
|
652
|
+
bias_detected = len(bias_types) > 0
|
|
653
|
+
|
|
654
|
+
if bias_detected:
|
|
655
|
+
avg_score = np.mean(list(bias_scores.values()))
|
|
656
|
+
if avg_score > 0.2:
|
|
657
|
+
bias_level = 'high'
|
|
658
|
+
elif avg_score > 0.1:
|
|
659
|
+
bias_level = 'medium'
|
|
660
|
+
else:
|
|
661
|
+
bias_level = 'low'
|
|
662
|
+
else:
|
|
663
|
+
bias_level = 'none'
|
|
664
|
+
|
|
665
|
+
return BiasReport(
|
|
666
|
+
bias_detected=bias_detected,
|
|
667
|
+
bias_level=bias_level,
|
|
668
|
+
bias_types=bias_types,
|
|
669
|
+
bias_scores=bias_scores,
|
|
670
|
+
protected_attributes=list(protected_data.keys()),
|
|
671
|
+
recommendations=recommendations,
|
|
672
|
+
metadata={'n_explanations': len(explanations)}
|
|
673
|
+
)
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
class ComprehensiveBiasAuditor:
|
|
677
|
+
"""
|
|
678
|
+
Comprehensive bias auditing system.
|
|
679
|
+
|
|
680
|
+
Combines data, model, and explanation bias detection into a
|
|
681
|
+
unified audit report.
|
|
682
|
+
|
|
683
|
+
Parameters
|
|
684
|
+
----------
|
|
685
|
+
protected_attributes : list of str
|
|
686
|
+
Protected attribute names.
|
|
687
|
+
thresholds : dict, optional
|
|
688
|
+
Custom thresholds for different bias types.
|
|
689
|
+
|
|
690
|
+
Examples
|
|
691
|
+
--------
|
|
692
|
+
>>> auditor = ComprehensiveBiasAuditor(protected_attributes=['gender', 'race'])
|
|
693
|
+
>>> audit_report = auditor.audit(
|
|
694
|
+
... X_train, y_train, protected_train,
|
|
695
|
+
... model, X_test, y_test, protected_test,
|
|
696
|
+
... explanations
|
|
697
|
+
... )
|
|
698
|
+
"""
|
|
699
|
+
|
|
700
|
+
def __init__(
|
|
701
|
+
self,
|
|
702
|
+
protected_attributes: List[str],
|
|
703
|
+
thresholds: Optional[Dict[str, float]] = None
|
|
704
|
+
):
|
|
705
|
+
self.protected_attributes = protected_attributes
|
|
706
|
+
self.thresholds = thresholds or {}
|
|
707
|
+
|
|
708
|
+
# Initialize detectors
|
|
709
|
+
self.data_detector = DataBiasDetector(
|
|
710
|
+
protected_attributes,
|
|
711
|
+
threshold=self.thresholds.get('data', 0.1)
|
|
712
|
+
)
|
|
713
|
+
|
|
714
|
+
self.model_detector = ModelBiasDetector(
|
|
715
|
+
protected_attributes,
|
|
716
|
+
fairness_threshold=self.thresholds.get('model', 0.8)
|
|
717
|
+
)
|
|
718
|
+
|
|
719
|
+
self.explanation_detector = ExplanationBiasDetector(
|
|
720
|
+
protected_attributes,
|
|
721
|
+
threshold=self.thresholds.get('explanation', 0.1)
|
|
722
|
+
)
|
|
723
|
+
|
|
724
|
+
def audit(
|
|
725
|
+
self,
|
|
726
|
+
X_train: np.ndarray,
|
|
727
|
+
y_train: np.ndarray,
|
|
728
|
+
protected_train: Dict[str, np.ndarray],
|
|
729
|
+
model: Any,
|
|
730
|
+
X_test: np.ndarray,
|
|
731
|
+
y_test: np.ndarray,
|
|
732
|
+
protected_test: Dict[str, np.ndarray],
|
|
733
|
+
explanations: Optional[List[ExplanationResult]] = None,
|
|
734
|
+
protected_attr_indices: Optional[Dict[str, List[int]]] = None
|
|
735
|
+
) -> Dict[str, BiasReport]:
|
|
736
|
+
"""
|
|
737
|
+
Complete bias audit.
|
|
738
|
+
|
|
739
|
+
Parameters
|
|
740
|
+
----------
|
|
741
|
+
X_train : ndarray
|
|
742
|
+
Training features.
|
|
743
|
+
y_train : ndarray
|
|
744
|
+
Training labels.
|
|
745
|
+
protected_train : dict
|
|
746
|
+
Protected attributes for training.
|
|
747
|
+
model : object
|
|
748
|
+
Trained model.
|
|
749
|
+
X_test : ndarray
|
|
750
|
+
Test features.
|
|
751
|
+
y_test : ndarray
|
|
752
|
+
Test labels.
|
|
753
|
+
protected_test : dict
|
|
754
|
+
Protected attributes for test.
|
|
755
|
+
explanations : list of ExplanationResult, optional
|
|
756
|
+
Explanations to audit.
|
|
757
|
+
protected_attr_indices : dict, optional
|
|
758
|
+
Feature indices of protected attributes.
|
|
759
|
+
|
|
760
|
+
Returns
|
|
761
|
+
-------
|
|
762
|
+
audit_report : dict
|
|
763
|
+
Complete audit with data, model, and explanation bias reports.
|
|
764
|
+
"""
|
|
765
|
+
audit_report = {}
|
|
766
|
+
|
|
767
|
+
# Data bias
|
|
768
|
+
print("Auditing data bias...")
|
|
769
|
+
data_report = self.data_detector.detect(X_train, y_train, protected_train)
|
|
770
|
+
audit_report['data_bias'] = data_report
|
|
771
|
+
|
|
772
|
+
# Model bias
|
|
773
|
+
print("Auditing model bias...")
|
|
774
|
+
model_report = self.model_detector.detect(model, X_test, y_test, protected_test)
|
|
775
|
+
audit_report['model_bias'] = model_report
|
|
776
|
+
|
|
777
|
+
# Explanation bias (if explanations provided)
|
|
778
|
+
if explanations:
|
|
779
|
+
print("Auditing explanation bias...")
|
|
780
|
+
explanation_report = self.explanation_detector.detect(
|
|
781
|
+
explanations,
|
|
782
|
+
protected_test,
|
|
783
|
+
protected_attr_indices
|
|
784
|
+
)
|
|
785
|
+
audit_report['explanation_bias'] = explanation_report
|
|
786
|
+
|
|
787
|
+
# Overall summary
|
|
788
|
+
all_biased = (
|
|
789
|
+
data_report.bias_detected or
|
|
790
|
+
model_report.bias_detected or
|
|
791
|
+
(explanations and audit_report.get('explanation_bias', BiasReport(False, 'none', [], {}, [], [], {})).bias_detected)
|
|
792
|
+
)
|
|
793
|
+
|
|
794
|
+
audit_report['summary'] = {
|
|
795
|
+
'overall_bias_detected': all_biased,
|
|
796
|
+
'data_bias_detected': data_report.bias_detected,
|
|
797
|
+
'model_bias_detected': model_report.bias_detected,
|
|
798
|
+
'explanation_bias_detected': audit_report.get('explanation_bias', BiasReport(False, 'none', [], {}, [], [], {})).bias_detected,
|
|
799
|
+
'all_recommendations': (
|
|
800
|
+
data_report.recommendations +
|
|
801
|
+
model_report.recommendations +
|
|
802
|
+
audit_report.get('explanation_bias', BiasReport(False, 'none', [], {}, [], [], {})).recommendations
|
|
803
|
+
)
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
return audit_report
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
# =============================================================================
|
|
810
|
+
# Example Usage
|
|
811
|
+
# =============================================================================
|
|
812
|
+
|
|
813
|
+
if __name__ == "__main__":
|
|
814
|
+
print("=" * 80)
|
|
815
|
+
print("Advanced Bias Detection System - Example")
|
|
816
|
+
print("=" * 80)
|
|
817
|
+
|
|
818
|
+
# Generate synthetic biased dataset
|
|
819
|
+
np.random.seed(42)
|
|
820
|
+
|
|
821
|
+
n_samples = 1000
|
|
822
|
+
n_features = 5
|
|
823
|
+
|
|
824
|
+
# Protected attribute: gender (0 = female, 1 = male)
|
|
825
|
+
# Biased: 70% male, 30% female
|
|
826
|
+
gender = np.random.choice([0, 1], size=n_samples, p=[0.3, 0.7])
|
|
827
|
+
|
|
828
|
+
# Features
|
|
829
|
+
X = np.random.randn(n_samples, n_features)
|
|
830
|
+
|
|
831
|
+
# Biased labels: higher approval rate for males
|
|
832
|
+
y = ((X[:, 0] + X[:, 1] + 0.5 * gender) > 0).astype(int)
|
|
833
|
+
|
|
834
|
+
# Split
|
|
835
|
+
split = 800
|
|
836
|
+
X_train, X_test = X[:split], X[split:]
|
|
837
|
+
y_train, y_test = y[:split], y[split:]
|
|
838
|
+
gender_train, gender_test = gender[:split], gender[split:]
|
|
839
|
+
|
|
840
|
+
protected_train = {'gender': gender_train}
|
|
841
|
+
protected_test = {'gender': gender_test}
|
|
842
|
+
|
|
843
|
+
# Simple biased model
|
|
844
|
+
class BiasedModel:
|
|
845
|
+
def predict(self, X):
|
|
846
|
+
# Simplified: uses gender in prediction
|
|
847
|
+
gender_idx = 0 # Assume gender is accessible
|
|
848
|
+
return (X[:, 0] + X[:, 1] > 0).astype(int)
|
|
849
|
+
|
|
850
|
+
def predict_proba(self, X):
|
|
851
|
+
pred = self.predict(X)
|
|
852
|
+
return np.column_stack([1 - pred, pred])
|
|
853
|
+
|
|
854
|
+
model = BiasedModel()
|
|
855
|
+
|
|
856
|
+
print("\n1. DATA BIAS DETECTION")
|
|
857
|
+
print("-" * 80)
|
|
858
|
+
data_detector = DataBiasDetector(protected_attributes=['gender'])
|
|
859
|
+
data_bias_report = data_detector.detect(X_train, y_train, protected_train)
|
|
860
|
+
|
|
861
|
+
print(f"Bias detected: {data_bias_report.bias_detected}")
|
|
862
|
+
print(f"Bias level: {data_bias_report.bias_level}")
|
|
863
|
+
print(f"Bias types: {data_bias_report.bias_types}")
|
|
864
|
+
print(f"Bias scores: {data_bias_report.bias_scores}")
|
|
865
|
+
print(f"Recommendations:")
|
|
866
|
+
for rec in data_bias_report.recommendations:
|
|
867
|
+
print(f" - {rec}")
|
|
868
|
+
|
|
869
|
+
print("\n2. MODEL BIAS DETECTION")
|
|
870
|
+
print("-" * 80)
|
|
871
|
+
model_detector = ModelBiasDetector(protected_attributes=['gender'], fairness_threshold=0.8)
|
|
872
|
+
model_bias_report = model_detector.detect(model, X_test, y_test, protected_test)
|
|
873
|
+
|
|
874
|
+
print(f"Bias detected: {model_bias_report.bias_detected}")
|
|
875
|
+
print(f"Bias level: {model_bias_report.bias_level}")
|
|
876
|
+
print(f"Bias types: {model_bias_report.bias_types}")
|
|
877
|
+
print(f"Bias scores: {model_bias_report.bias_scores}")
|
|
878
|
+
print(f"Recommendations:")
|
|
879
|
+
for rec in model_bias_report.recommendations:
|
|
880
|
+
print(f" - {rec}")
|
|
881
|
+
|
|
882
|
+
print("\n3. EXPLANATION BIAS DETECTION")
|
|
883
|
+
print("-" * 80)
|
|
884
|
+
|
|
885
|
+
# Generate mock explanations
|
|
886
|
+
explanations = []
|
|
887
|
+
for i in range(len(X_test)):
|
|
888
|
+
importance = np.array([0.3, 0.3, 0.1, 0.1, 0.2])
|
|
889
|
+
# Simulate bias: different importance for different genders
|
|
890
|
+
if gender_test[i] == 1:
|
|
891
|
+
importance[0] += 0.2
|
|
892
|
+
|
|
893
|
+
exp = ExplanationResult(
|
|
894
|
+
method='mock_shap',
|
|
895
|
+
explanation_data={'feature_importance': importance.tolist()},
|
|
896
|
+
metadata={}
|
|
897
|
+
)
|
|
898
|
+
explanations.append(exp)
|
|
899
|
+
|
|
900
|
+
explanation_detector = ExplanationBiasDetector(protected_attributes=['gender'])
|
|
901
|
+
explanation_bias_report = explanation_detector.detect(
|
|
902
|
+
explanations,
|
|
903
|
+
protected_test,
|
|
904
|
+
protected_attr_indices={}
|
|
905
|
+
)
|
|
906
|
+
|
|
907
|
+
print(f"Bias detected: {explanation_bias_report.bias_detected}")
|
|
908
|
+
print(f"Bias level: {explanation_bias_report.bias_level}")
|
|
909
|
+
print(f"Bias types: {explanation_bias_report.bias_types}")
|
|
910
|
+
print(f"Bias scores: {explanation_bias_report.bias_scores}")
|
|
911
|
+
|
|
912
|
+
print("\n4. COMPREHENSIVE BIAS AUDIT")
|
|
913
|
+
print("-" * 80)
|
|
914
|
+
auditor = ComprehensiveBiasAuditor(protected_attributes=['gender'])
|
|
915
|
+
|
|
916
|
+
audit_report = auditor.audit(
|
|
917
|
+
X_train, y_train, protected_train,
|
|
918
|
+
model, X_test, y_test, protected_test,
|
|
919
|
+
explanations
|
|
920
|
+
)
|
|
921
|
+
|
|
922
|
+
print(f"\nAudit Summary:")
|
|
923
|
+
print(f" Overall bias detected: {audit_report['summary']['overall_bias_detected']}")
|
|
924
|
+
print(f" Data bias: {audit_report['summary']['data_bias_detected']}")
|
|
925
|
+
print(f" Model bias: {audit_report['summary']['model_bias_detected']}")
|
|
926
|
+
print(f" Explanation bias: {audit_report['summary']['explanation_bias_detected']}")
|
|
927
|
+
|
|
928
|
+
print(f"\nAll recommendations ({len(audit_report['summary']['all_recommendations'])} total):")
|
|
929
|
+
for i, rec in enumerate(audit_report['summary']['all_recommendations'], 1):
|
|
930
|
+
print(f" {i}. {rec}")
|
|
931
|
+
|
|
932
|
+
print("\n" + "=" * 80)
|
|
933
|
+
print("Advanced bias detection demonstration complete!")
|
|
934
|
+
print("=" * 80)
|