Skip to main content

XAI Text Classifier

A library to explain whether text is AI-generated or human-written using SHAP (SHapley Additive exPlanations).

Features

  • AI vs Human Text Classification: Distinguish between AI-generated and human-written text
  • Explainability: Uses SHAP to provide detailed feature importance explanations
  • Multiple Models: Includes XGBoost and Random Forest models for robust predictions
  • Comprehensive Feature Analysis: Analyzes 40+ linguistic features including:
    • Readability metrics
    • Sentiment analysis
    • Syntactic complexity
    • Stylistic patterns
    • And more

Installation

pip install xai-text-classifier

Or install from source:

git clone <repository-url>
cd xai-text-classifier
pip install -e .

Usage

from xai import shap_explainer

# Analyze text
text = "Your text here..."
result = shap_explainer(text)

# Returns:
# {
#     "prediction": 0 or 1,  # 0 = Human, 1 = AI
#     "features": {
#         "feature_name": {
#             "value": feature_value,
#             "shap_value": shap_contribution,
#             "importance": relative_importance
#         },
#         ...
#     }
# }

Requirements

  • Python >= 3.8
  • joblib
  • shap
  • xgboost
  • spacy
  • language-tool-python
  • textblob
  • pandas
  • numpy
  • scikit-learn
  • nltk
  • textstat
  • matplotlib
  • scipy

Development

Install development dependencies:

pip install -e ".[dev]"

Run tests:

pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use this library in your research, please cite:

@software{xai_text_classifier,
  title={XAI Text Classifier},
  year={2025},
  url={<repository-url>}
}

Download files

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

Source Distribution

xai_text_classifier-0.1.3.2.6.tar.gz (5.3 MB view details)

Uploaded Source

Built Distribution

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

xai_text_classifier-0.1.3.2.6-py3-none-any.whl (5.5 MB view details)

Uploaded Python 3

File details

Details for the file xai_text_classifier-0.1.3.2.6.tar.gz.

File metadata

  • Download URL: xai_text_classifier-0.1.3.2.6.tar.gz
  • Upload date:
  • Size: 5.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for xai_text_classifier-0.1.3.2.6.tar.gz
Algorithm Hash digest
SHA256 fc58cacd6145e3c0cbcd2aed0c100116412ff923d945d50440b2ac569c421bc2
MD5 c8eb98c498253402131a50f374ceb0a5
BLAKE2b-256 8b806d41dd7b15126ea28a0f855aa0b1dc5bd5d34519ce16d94ad607f03e799a

See more details on using hashes here.

File details

Details for the file xai_text_classifier-0.1.3.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for xai_text_classifier-0.1.3.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 64426917a565843c979e61232051c821d8a9ea18648c7a0dd1cba7188891149b
MD5 bb1cc8fde6eec86747a72c50fe26a443
BLAKE2b-256 4b72e7c0c40d6212f7629435c1909f8d56dfdb207a478592d29c3639068807a9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.3.2.6 This release

2 files

0.1.3.2.5

2 files

0.1.3.2.4

2 files

0.1.3.2.3

2 files

0.1.3.2.2

2 files

0.1.3.2.1

2 files

0.1.3.2

2 files

0.1.3.1

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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