A library to explain whether text is AI-generated or human-written using SHAP
Project description
Detect and explain AI generated text
A library to detect and 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 explain_ai_generated_text
Or install from source:
git clone <repository-url>
cd explain_ai_generated_text
pip install -e .
Usage
from explain_ai_generated_text 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{explain_ai_generated_text,
title={Explainable AI Generated Text Detection},
year={2025},
url={<repository-url>}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file explain_ai_generated_text-0.1.1.1.7.tar.gz.
File metadata
- Download URL: explain_ai_generated_text-0.1.1.1.7.tar.gz
- Upload date:
- Size: 5.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0426caaf3e79b5a017939be7bdd30f3dc9f72904c03037de2fb0db1b33d44a7e
|
|
| MD5 |
87028196386efa58cc502fd8f9bdd2ee
|
|
| BLAKE2b-256 |
cde518bb17db7859f0b62374c855694342e1984773cdd0165db5d3ca0751f985
|
File details
Details for the file explain_ai_generated_text-0.1.1.1.7-py3-none-any.whl.
File metadata
- Download URL: explain_ai_generated_text-0.1.1.1.7-py3-none-any.whl
- Upload date:
- Size: 5.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ddc6c63e3ffdfacb992bbfa5f79589c0078a552ceee9eae1bcc5e4ceeb8332d
|
|
| MD5 |
e58d15bcd7704ea3301d23288d5a6874
|
|
| BLAKE2b-256 |
d7724b2065630357f4c73bdd400b3e33292ef285487902e9f8cc1ce6e313a4db
|