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>}
}
Metadata
Release files for xai-text-classifier 0.1.3.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xai_text_classifier-0.1.3.2.6.tar.gz | 5.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xai_text_classifier-0.1.3.2.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 MB
Release files / xai_text_classifier-0.1.3.2.6.tar.gz
| Download URL | xai_text_classifier-0.1.3.2.6.tar.gz |
|---|---|
| Size | 5.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc58cacd6145e3c0cbcd2aed0c100116412ff923d945d50440b2ac569c421bc2
|
|
BLAKE2b-256 checksum How to use checksums |
8b806d41dd7b15126ea28a0f855aa0b1dc5bd5d34519ce16d94ad607f03e799a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / xai_text_classifier-0.1.3.2.6-py3-none-any.whl
| Download URL | xai_text_classifier-0.1.3.2.6-py3-none-any.whl |
|---|---|
| Size | 5.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64426917a565843c979e61232051c821d8a9ea18648c7a0dd1cba7188891149b
|
|
BLAKE2b-256 checksum How to use checksums |
4b72e7c0c40d6212f7629435c1909f8d56dfdb207a478592d29c3639068807a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|