Skip to main content

TorchXAI is a PyTorch-based toolkit designed for evaluating machine learning models using explainability techniques.

Project description

TorchXAI

TorchXAI is a PyTorch-based toolkit designed for evaluating machine learning models using explainability techniques.

Description

TorchXAI provides efficient implementations of several XAI (Explainable AI) metrics that seamlessly integrate with the Captum library. The primary goal of this toolkit is to offer batch computation and task/data-agnostic implementations of various explainability metrics, enabling scalable evaluation while maintaining compatibility with the established Captum framework.

Installation with Pip

The project can be installed directly with pip:

pip install git+https://github.com/saifullah3396/torchxai.git

Installation from Source

Clone the repository:

git clone https://github.com/saifullah3396/torchxai.git

Install the project with pip on source directory

pip install -e .

Usage

Import the required metric, such as completeness

from torchxai.metrics.axiomatic import completeness
from captum.attr import Saliency

# ImageClassifier takes a single input tensor of images Nx3x32x32,
# and returns an Nx10 tensor of class probabilities.
net = ImageClassifier()

saliency = Saliency(net)
input = torch.randn(2, 3, 32, 32, requires_grad=True)
baselines = torch.zeros(2, 3, 32, 32)

# Computes saliency maps for class 3.
attribution = saliency.attribute(input, target=3)

# define a perturbation function for the input
# Computes completeness score for saliency maps
completeness_score = completeness(net, input, attribution, baselines)

Project details


Download files

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

Source Distribution

torchxai_tools-1.0.3.tar.gz (116.4 kB view details)

Uploaded Source

Built Distribution

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

torchxai_tools-1.0.3-py3-none-any.whl (161.6 kB view details)

Uploaded Python 3

File details

Details for the file torchxai_tools-1.0.3.tar.gz.

File metadata

  • Download URL: torchxai_tools-1.0.3.tar.gz
  • Upload date:
  • Size: 116.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.22

File hashes

Hashes for torchxai_tools-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e379372d381b2527326adc7aea9efdf9ea5e4a2f829cf2843aa2372d2fed7dfd
MD5 f0df45263671f8d8e165747fc3281348
BLAKE2b-256 9689e8447bb781104a5ebdb180529c0ed117df5f77297b37eacf20a20044dfc6

See more details on using hashes here.

File details

Details for the file torchxai_tools-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for torchxai_tools-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8f5af93352ef70ea4b501b2a877b22ba8a7e80c71424f70e327692d23b525a46
MD5 b20c19be085962aca51db16ee3a5a2cd
BLAKE2b-256 98c8b7862452b64a82dd8da1dc75d94c52d13a4e3b8ebab967f4bfe6abeb9e37

See more details on using hashes here.

Supported by

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