# AryaXai-Backtrace
Backtrace module for Generating Explainability on Deep learning models using TensorFlow / Pytorch
# Backtrace Module
[](LICENSE)
## Overview
The Backtrace Module is a powerful and patent-pending algorithm developed by AryaXAI for enhancing the explainability of AI models, particularly in the context of complex techniques like deep learning.
## Features
- **Explainability:** Gain deep insights into your AI models by using the Backtrace algorithm, providing multiple explanations for their decisions.
- **Consistency:** Ensure consistent and accurate explanations across different scenarios and use cases.
- **Mission-Critical Support:** Tailored for mission-critical AI use cases where transparency is paramount.
## Installation
To integrate the Backtrace Module into your project, follow these simple steps:
```bash
pip install dl-backtrace
```
## Usage
### Tensoflow-Keras based models
```python
from dl_backtrace.tf_backtrace import Backtrace as B
```
### Pytorch based models
```python
from dl_backtrace.pytorch_backtrace import Backtrace as B
```
### Evalauting using Backtrace:
1. Step - 1: Initialize a Backtrace Object using your Model
```python
backtrace = B(model=model)
```
2. Step - 2: Calculate layer-wise output using a data instance
```python
layer_outputs = backtrace.predict(test_data[0])
```
3. Step - 3: Calculate layer-wise Relevance using Evaluation
```python
relevance = backtrace.eval(layer_outputs,mode='default',scaler=1,thresholding=0.5,task="binary-classification")
```
#### Depending on Task we have several attributes for Relevance Calculation in Evalaution:
| Attribute | Description | Values |
|--------------|-------------|--------|
| mode | evaluation mode of algorithm | { default, contrastive}|
| scaler | Total / Starting Relevance at the Last Layer | Integer ( Default: None, Preferred: 1)|
| thresholding | Thresholding Model Prediction in Segemntation Task to select Pixels predicting the actual class. (Only works in Segmentation Tasks) | Default:0.5 |
| task | The task of the Model | { binary-classification, multi-class classification, bbox-regression, binary-segmentation} |
| model-type | Type of the Model | {Encoder/ Encoder_Decoder} |
## Example Notebooks :
### Tensorflow-Keras :
| Name | Task | Link |
|-------------|-------------|-------------------------------|
| Backtrace Loan Classification Tabular Dataset | Binary Classification | [Colab Link](https://colab.research.google.com/drive/1H5jaryVPEAQuqk9XPP71UIL4cemli98K?usp=sharing) |
| Backtrace Image FMNIST Dataset | Multi-Class Classification | [Colab Link](https://colab.research.google.com/drive/1BZsdo7IWYGhdy0Pg_m8r7c3COczuW_tG?usp=sharing) |
| Backtrace CUB Bounding Box Regression Image Dataset | Single Object Detection | [Colab Link](https://colab.research.google.com/drive/15mmJ2aGt-_Ho7RdPWjNEEoFXE9mu9HLV?usp=sharing) |
| Backtrace Next Word Generation Textual Dataset | Next Word Generation | [Colab Link](https://colab.research.google.com/drive/14R3DuDLjvgowA2ucsoccpyN7Lp-ZOAz4?usp=sharing) |
| Backtrace ImDB Sentiment Classification Textual Dataset | Sentiment Classification | [Colab Link](https://colab.research.google.com/drive/1Kgthc7rbaNsSqLuH7RPm_vRIPB98uoCW?usp=sharing)|
| Backtrace Binary Classification Textual Dataset | Binary Classification | [Colab Link](https://colab.research.google.com/drive/1C1M2uNXi1WjpC1N74wl3bbQOIFNm57No?usp=sharing) |
| Backtrace Multi-Class NewsGroup20 Classification Textual Dataset | Multi-Class Classification | [Colab Link](https://colab.research.google.com/drive/1xqBuix5qk0mDSxMScubO4ENeMb8F9IgE?usp=sharing) |
| Backtrace CVC-ClinicDB Colonoscopy Binary Segmentation | Organ Segmentation | [Colab Link](https://colab.research.google.com/drive/1cUNUao7fahDgndVI-cpn2iSByTiWaB4j?usp=sharing) |
| Backtrace CamVid Road Car Binary Segmentation | Binary Segmentation | [Colab Link](https://colab.research.google.com/drive/1OAY7aAraKq_ucyVt5AYPBD8LkQOIuy1C?usp=sharing) |
| Backtrace Transformer Encoder for Sentiment Analysis | Binary Classification | [Colab Link](https://colab.research.google.com/drive/1H7-4ox3YWMtoH0vptYGXaN63PRJFbTrX?usp=sharing) |
| Backtrace Transformer Encoder-Decoder Model for Neural Machine Translation | Neural Machine Translation | [Colab Link](https://colab.research.google.com/drive/1NApbrd11TEqlrqGCBYPmgMvBbZBJhpWD?usp=sharing) |
| Backtrace Transformer Encoder-Decoder Model for Text Summarization | Text Summarization | [Colab Link](https://colab.research.google.com/drive/18CPNnEJzGlCPJ2sSXX4mArAzK1NLe9Lj?usp=sharing) |
### Pytorch :
| Name | Task | Link |
|-------------|-------------|-------------------------------|
| Backtrace Tabular Dataset | Binary Classification | [Colab Link](https://colab.research.google.com/drive/1_r-IS7aIuATSvGNRLk8VDVVLkDSaKCpD?usp=sharing)|
| Backtrace Image Dataset | Multi-Class Classification | [Colab Link](https://colab.research.google.com/drive/1v2XajWtIbf7Vt31Z1fnKnAjyiDzPxwnU?usp=sharing) |
For more detailed examples and use cases, check out our documentation.
## Supported Layers and Future Work :
### Tensorflow-Keras:
- [x] Dense (Fully Connected) Layer
- [x] Convolutional Layer (Conv2D,Conv1D)
- [x] Transpose Convolutional Layer (Conv2DTranspose,Conv1DTranspose)
- [x] Reshape Layer
- [x] Flatten Layer
- [x] Global Max Pooling (2D & 1D) Layer
- [x] Global Average Pooling (2D & 1D) Layer
- [x] Max Pooling (2D & 1D) Layer
- [x] Average Pooling (2D & 1D) Layer
- [x] Concatenate Layer
- [x] Add Layer
- [x] Long Short-Term Memory (LSTM) Layer
- [x] Dropout Layer
- [x] Embedding Layer
- [x] TextVectorization Layer
- [x] Self-Attention Layer
- [x] Cross-Attention Layer
- [x] Feed-Forward Layer
- [x] Pooler Layer
- [x] Decoder LM (Language Model) Head
- [ ] Other Custom Layers
### Pytorch :
(Note: Currently we only Support Binary and Multi-Class Classification in Pytorch, Segmentation and Single Object Detection will be supported in the next release.)
- [x] Linear (Fully Connected) Layer
- [x] Convolutional Layer (Conv2D)
- [x] Reshape Layer
- [x] Flatten Layer
- [x] Global Average Pooling 2D Layer (AdaptiveAvgPool2d)
- [x] Max Pooling 2D Layer (MaxPool2d)
- [x] Average Pooling 2D Layer (AvgPool2d)
- [x] Concatenate Layer
- [x] Add Layer
- [x] Long Short-Term Memory (LSTM) Layer
- [ ] Dropout Layer
- [ ] Embedding Layer
- [ ] EmbeddingBag Layer
- [ ] 1d Convolution Layer (Conv1d)
- [ ] 1d Pooling Layers (AvgPool1d,MaxPool1d,AdaptiveAvgPool1d,AdaptiveMaxPool1d)
- [ ] Transpose Convolution Layers (ConvTranspose2d,ConvTranspose1d)
- [ ] Global Max Pooling 2D Layer (AdaptiveMaxPool2d)
- [ ] Other Custom Layers
## Getting Started
If you are new to Backtrace, head over to our Getting Started Guide to quickly set up and use the module in your projects.
## Contributing
We welcome contributions from the community. To contribute, please follow our Contribution Guidelines.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Contact
For any inquiries or support, please contact AryaXAI Support.
Raw data
{
"_id": null,
"home_page": "https://xai.arya.ai/docs/introduction",
"name": "dl-backtrace",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.0",
"maintainer_email": null,
"keywords": "aryaxai deep learning backtrace, ML observability",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/f3/72/257ab838009de2da7c2e31cd7529d07e6a3ed051bc29b72b96eaa27ad3a2/dl_backtrace-0.0.24.tar.gz",
"platform": null,
"description": "# AryaXai-Backtrace\nBacktrace module for Generating Explainability on Deep learning models using TensorFlow / Pytorch\n\n# Backtrace Module\n[](LICENSE)\n\n## Overview\n\nThe Backtrace Module is a powerful and patent-pending algorithm developed by AryaXAI for enhancing the explainability of AI models, particularly in the context of complex techniques like deep learning.\n\n## Features\n\n- **Explainability:** Gain deep insights into your AI models by using the Backtrace algorithm, providing multiple explanations for their decisions.\n\n- **Consistency:** Ensure consistent and accurate explanations across different scenarios and use cases.\n\n- **Mission-Critical Support:** Tailored for mission-critical AI use cases where transparency is paramount.\n\n## Installation\n\nTo integrate the Backtrace Module into your project, follow these simple steps:\n\n```bash\npip install dl-backtrace\n```\n\n## Usage \n\n### Tensoflow-Keras based models\n\n```python\nfrom dl_backtrace.tf_backtrace import Backtrace as B\n```\n\n### Pytorch based models\n\n```python\nfrom dl_backtrace.pytorch_backtrace import Backtrace as B\n```\n\n### Evalauting using Backtrace:\n\n1. Step - 1: Initialize a Backtrace Object using your Model\n```python\nbacktrace = B(model=model)\n```\n\n2. Step - 2: Calculate layer-wise output using a data instance\n\n```python\nlayer_outputs = backtrace.predict(test_data[0])\n```\n\n3. Step - 3: Calculate layer-wise Relevance using Evaluation \n```python\nrelevance = backtrace.eval(layer_outputs,mode='default',scaler=1,thresholding=0.5,task=\"binary-classification\")\n```\n\n#### Depending on Task we have several attributes for Relevance Calculation in Evalaution:\n\n| Attribute | Description | Values |\n|--------------|-------------|--------|\n| mode | evaluation mode of algorithm | { default, contrastive}|\n| scaler | Total / Starting Relevance at the Last Layer | Integer ( Default: None, Preferred: 1)|\n| thresholding | Thresholding Model Prediction in Segemntation Task to select Pixels predicting the actual class. (Only works in Segmentation Tasks) | Default:0.5 |\n| task | The task of the Model | { binary-classification, multi-class classification, bbox-regression, binary-segmentation} |\n| model-type | Type of the Model | {Encoder/ Encoder_Decoder} |\n\n## Example Notebooks : \n\n### Tensorflow-Keras : \n\n| Name | Task | Link |\n|-------------|-------------|-------------------------------|\n| Backtrace Loan Classification Tabular Dataset | Binary Classification | [Colab Link](https://colab.research.google.com/drive/1H5jaryVPEAQuqk9XPP71UIL4cemli98K?usp=sharing) |\n| Backtrace Image FMNIST Dataset | Multi-Class Classification | [Colab Link](https://colab.research.google.com/drive/1BZsdo7IWYGhdy0Pg_m8r7c3COczuW_tG?usp=sharing) |\n| Backtrace CUB Bounding Box Regression Image Dataset | Single Object Detection | [Colab Link](https://colab.research.google.com/drive/15mmJ2aGt-_Ho7RdPWjNEEoFXE9mu9HLV?usp=sharing) |\n| Backtrace Next Word Generation Textual Dataset | Next Word Generation | [Colab Link](https://colab.research.google.com/drive/14R3DuDLjvgowA2ucsoccpyN7Lp-ZOAz4?usp=sharing) |\n| Backtrace ImDB Sentiment Classification Textual Dataset | Sentiment Classification | [Colab Link](https://colab.research.google.com/drive/1Kgthc7rbaNsSqLuH7RPm_vRIPB98uoCW?usp=sharing)|\n| Backtrace Binary Classification Textual Dataset | Binary Classification | [Colab Link](https://colab.research.google.com/drive/1C1M2uNXi1WjpC1N74wl3bbQOIFNm57No?usp=sharing) |\n| Backtrace Multi-Class NewsGroup20 Classification Textual Dataset | Multi-Class Classification | [Colab Link](https://colab.research.google.com/drive/1xqBuix5qk0mDSxMScubO4ENeMb8F9IgE?usp=sharing) |\n| Backtrace CVC-ClinicDB Colonoscopy Binary Segmentation | Organ Segmentation | [Colab Link](https://colab.research.google.com/drive/1cUNUao7fahDgndVI-cpn2iSByTiWaB4j?usp=sharing) | \n| Backtrace CamVid Road Car Binary Segmentation | Binary Segmentation | [Colab Link](https://colab.research.google.com/drive/1OAY7aAraKq_ucyVt5AYPBD8LkQOIuy1C?usp=sharing) |\n| Backtrace Transformer Encoder for Sentiment Analysis | Binary Classification | [Colab Link](https://colab.research.google.com/drive/1H7-4ox3YWMtoH0vptYGXaN63PRJFbTrX?usp=sharing) |\n| Backtrace Transformer Encoder-Decoder Model for Neural Machine Translation | Neural Machine Translation | [Colab Link](https://colab.research.google.com/drive/1NApbrd11TEqlrqGCBYPmgMvBbZBJhpWD?usp=sharing) |\n| Backtrace Transformer Encoder-Decoder Model for Text Summarization | Text Summarization | [Colab Link](https://colab.research.google.com/drive/18CPNnEJzGlCPJ2sSXX4mArAzK1NLe9Lj?usp=sharing) |\n\n### Pytorch : \n| Name | Task | Link |\n|-------------|-------------|-------------------------------|\n| Backtrace Tabular Dataset | Binary Classification | [Colab Link](https://colab.research.google.com/drive/1_r-IS7aIuATSvGNRLk8VDVVLkDSaKCpD?usp=sharing)|\n| Backtrace Image Dataset | Multi-Class Classification | [Colab Link](https://colab.research.google.com/drive/1v2XajWtIbf7Vt31Z1fnKnAjyiDzPxwnU?usp=sharing) |\n\nFor more detailed examples and use cases, check out our documentation.\n\n## Supported Layers and Future Work :\n\n### Tensorflow-Keras:\n\n- [x] Dense (Fully Connected) Layer\n- [x] Convolutional Layer (Conv2D,Conv1D)\n- [x] Transpose Convolutional Layer (Conv2DTranspose,Conv1DTranspose)\n- [x] Reshape Layer\n- [x] Flatten Layer\n- [x] Global Max Pooling (2D & 1D) Layer\n- [x] Global Average Pooling (2D & 1D) Layer\n- [x] Max Pooling (2D & 1D) Layer\n- [x] Average Pooling (2D & 1D) Layer\n- [x] Concatenate Layer\n- [x] Add Layer\n- [x] Long Short-Term Memory (LSTM) Layer\n- [x] Dropout Layer\n- [x] Embedding Layer\n- [x] TextVectorization Layer\n- [x] Self-Attention Layer\n- [x] Cross-Attention Layer\n- [x] Feed-Forward Layer\n- [x] Pooler Layer\n- [x] Decoder LM (Language Model) Head\n- [ ] Other Custom Layers \n\n### Pytorch :\n\n(Note: Currently we only Support Binary and Multi-Class Classification in Pytorch, Segmentation and Single Object Detection will be supported in the next release.)\n\n- [x] Linear (Fully Connected) Layer\n- [x] Convolutional Layer (Conv2D)\n- [x] Reshape Layer\n- [x] Flatten Layer\n- [x] Global Average Pooling 2D Layer (AdaptiveAvgPool2d)\n- [x] Max Pooling 2D Layer (MaxPool2d)\n- [x] Average Pooling 2D Layer (AvgPool2d)\n- [x] Concatenate Layer\n- [x] Add Layer\n- [x] Long Short-Term Memory (LSTM) Layer\n- [ ] Dropout Layer\n- [ ] Embedding Layer\n- [ ] EmbeddingBag Layer\n- [ ] 1d Convolution Layer (Conv1d)\n- [ ] 1d Pooling Layers (AvgPool1d,MaxPool1d,AdaptiveAvgPool1d,AdaptiveMaxPool1d)\n- [ ] Transpose Convolution Layers (ConvTranspose2d,ConvTranspose1d)\n- [ ] Global Max Pooling 2D Layer (AdaptiveMaxPool2d)\n- [ ] Other Custom Layers\n\n\n## Getting Started\nIf you are new to Backtrace, head over to our Getting Started Guide to quickly set up and use the module in your projects.\n\n## Contributing\nWe welcome contributions from the community. To contribute, please follow our Contribution Guidelines.\n\n## License\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Contact\nFor any inquiries or support, please contact AryaXAI Support.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A python SDK for Deep Learning Backtrace",
"version": "0.0.24",
"project_urls": {
"Homepage": "https://xai.arya.ai/docs/introduction"
},
"split_keywords": [
"aryaxai deep learning backtrace",
" ml observability"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d0d4aa244e86c08e9e18550fb7fa3aeba44618bec261bb4943ea21e4588803a6",
"md5": "c44baf64a7573a6aadce5531e3ff68b4",
"sha256": "e0c6b167bfdf8d5bea6c3831fea06b4c0da2215386d1a16a87d02bde5b243843"
},
"downloads": -1,
"filename": "dl_backtrace-0.0.24-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c44baf64a7573a6aadce5531e3ff68b4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.0",
"size": 101804,
"upload_time": "2025-01-30T11:43:46",
"upload_time_iso_8601": "2025-01-30T11:43:46.707321Z",
"url": "https://files.pythonhosted.org/packages/d0/d4/aa244e86c08e9e18550fb7fa3aeba44618bec261bb4943ea21e4588803a6/dl_backtrace-0.0.24-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f372257ab838009de2da7c2e31cd7529d07e6a3ed051bc29b72b96eaa27ad3a2",
"md5": "634a84c39a2c4ea681df4bf05f9c3123",
"sha256": "f1ffafe2be6d4121d4ee34a5638c15ffd07d8922192b2b8b263f3451739668ea"
},
"downloads": -1,
"filename": "dl_backtrace-0.0.24.tar.gz",
"has_sig": false,
"md5_digest": "634a84c39a2c4ea681df4bf05f9c3123",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.0",
"size": 91452,
"upload_time": "2025-01-30T11:43:48",
"upload_time_iso_8601": "2025-01-30T11:43:48.023605Z",
"url": "https://files.pythonhosted.org/packages/f3/72/257ab838009de2da7c2e31cd7529d07e6a3ed051bc29b72b96eaa27ad3a2/dl_backtrace-0.0.24.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-30 11:43:48",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "dl-backtrace"
}