# ramishazia01/ext-shap-lime-xai architecture

> Architecture diagram of the GitHub repository ramishazia01/ext-shap-lime-xai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ramishazia01/ext-shap-lime-xai
- Repository: https://github.com/ramishazia01/ext-shap-lime-xai

## Overview

This repository provides two RTL-language explainability paths: SHAP explanations and plots, plus LIME text explanations, with Urdu/Arabic/Persian/Hebrew text handling. The main workflow accepts text/model inputs, computes feature attributions, optionally translates or interprets them with an LLM, and presents textual analyses or RTL-aware plots. The SHAP wrapper supports model fitting and prediction; the package also exposes drop-in RTL plot variants. The LIME implementation and SHAP internals are sampled only partially, so uncertain links are omitted.

Main entry points: [`LIME_RTL/src/urdu_lime/explainer.py`](https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/LIME_RTL/src/urdu_lime/explainer.py) (LIME explainer), [`SHAP_RTL/shap_rtl/wrapper.py`](https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/wrapper.py) (Model wrapper), [`SHAP_RTL/shap_rtl/explainer.py`](https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/explainer.py) (SHAP explainer), [`SHAP_RTL/shap_rtl/plots`](https://github.com/ramishazia01/ext-shap-lime-xai/tree/main/SHAP_RTL/shap_rtl/plots) (RTL plot suite)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shap["SHAP explainability"]
  node_wrapper["Model wrapper<br/>[wrapper.py]"]
  node_shap_explainer["SHAP explainer<br/>[explainer.py]"]
end

subgraph group_lime["LIME explainability"]
  node_lime_explainer["LIME explainer<br/>[explainer.py]"]
end

subgraph group_render["RTL rendering"]
  node_rtl_plots["RTL plot suite"]
  node_rtl_utils["RTL text utilities<br/>[rtl_utils.py]"]
  node_hebrew_utils["Hebrew utilities"]
end

subgraph group_external["External services"]
  node_shap_api["SHAP library"]
  node_lime_library["LIME text engine"]
  node_llm["LLM service"]
end

node_user(("Engineer or user"))
node_model["Classifier model"]
node_visual_output["Rendered plots"]
node_text_output["Text analysis"]

node_user -->|"supplies texts"| node_wrapper
node_user -->|"supplies SHAP values"| node_shap_explainer
node_wrapper -->|"fits and predicts"| node_model
node_wrapper -->|"computes attributions"| node_shap_api
node_wrapper -->|"requests analysis"| node_shap_explainer
node_wrapper -->|"selects plot"| node_rtl_plots
node_shap_explainer -->|"requests translations"| node_llm
node_shap_explainer -->|"renders explanation"| node_rtl_plots
node_rtl_plots -->|"shapes RTL text"| node_rtl_utils
node_rtl_plots -.->|"handles Hebrew text"| node_hebrew_utils
node_rtl_plots -->|"draws plots"| node_visual_output
node_user -->|"supplies text"| node_lime_explainer
node_lime_explainer -->|"generates local features"| node_lime_library
node_lime_explainer -->|"queries predictions"| node_model
node_lime_explainer -->|"requests analysis"| node_llm
node_lime_explainer -->|"prints analysis"| node_text_output
node_lime_explainer -->|"draws plots"| node_visual_output
node_shap_explainer -->|"prints explanations"| node_text_output

click node_wrapper "https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/wrapper.py"
click node_shap_explainer "https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/explainer.py"
click node_rtl_plots "https://github.com/ramishazia01/ext-shap-lime-xai/tree/main/SHAP_RTL/shap_rtl/plots"
click node_rtl_utils "https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/rtl_utils.py"
click node_hebrew_utils "https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/rtl_utils_hebrew.py"
click node_lime_explainer "https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/LIME_RTL/src/urdu_lime/explainer.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_wrapper,node_shap_explainer,node_user toneBlue
class node_lime_explainer toneAmber
class node_rtl_plots,node_rtl_utils,node_hebrew_utils toneMint
class node_shap_api,node_lime_library,node_llm toneRose
class node_model,node_visual_output,node_text_output toneIndigo
```

## Components

### SHAP explainability

- [Model wrapper](https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/wrapper.py): `SHAP_RTL/shap_rtl/wrapper.py`
- [SHAP explainer](https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/explainer.py): `SHAP_RTL/shap_rtl/explainer.py`

### LIME explainability

- [LIME explainer](https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/LIME_RTL/src/urdu_lime/explainer.py): `LIME_RTL/src/urdu_lime/explainer.py`

### RTL rendering

- [RTL plot suite](https://github.com/ramishazia01/ext-shap-lime-xai/tree/main/SHAP_RTL/shap_rtl/plots): `SHAP_RTL/shap_rtl/plots`
- [RTL text utilities](https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/rtl_utils.py): `SHAP_RTL/shap_rtl/rtl_utils.py`
- [Hebrew utilities](https://github.com/ramishazia01/ext-shap-lime-xai/blob/main/SHAP_RTL/shap_rtl/rtl_utils_hebrew.py): `SHAP_RTL/shap_rtl/rtl_utils_hebrew.py`

### External services

- **SHAP library**
- **LIME text engine**
- **LLM service**

### Other components

- **Engineer or user**
- **Classifier model**
- **Rendered plots**
- **Text analysis**

## Connections

- Engineer or user → Model wrapper: supplies texts
- Engineer or user → SHAP explainer: supplies SHAP values
- Model wrapper → Classifier model: fits and predicts
- Model wrapper → SHAP library: computes attributions
- Model wrapper → SHAP explainer: requests analysis
- Model wrapper → RTL plot suite: selects plot
- SHAP explainer → LLM service: requests translations
- SHAP explainer → RTL plot suite: renders explanation
- RTL plot suite → RTL text utilities: shapes RTL text
- RTL plot suite → Hebrew utilities: handles Hebrew text
- RTL plot suite → Rendered plots: draws plots
- Engineer or user → LIME explainer: supplies text
- LIME explainer → LIME text engine: generates local features
- LIME explainer → Classifier model: queries predictions
- LIME explainer → LLM service: requests analysis
- LIME explainer → Text analysis: prints analysis
- LIME explainer → Rendered plots: draws plots
- SHAP explainer → Text analysis: prints explanations
