A library to detect and explain whether text is AI-generated or human-written using SHAP (SHapley Additive exPlanations).
- 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
pip install explain_ai_generated_textOr install from source:
git clone <repository-url>
cd explain_ai_generated_text
pip install -e .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
# },
# ...
# }
# }- Python >= 3.8
- joblib
- shap
- xgboost
- spacy
- language-tool-python
- textblob
- pandas
- numpy
- scikit-learn
- nltk
- textstat
- matplotlib
- scipy
Install development dependencies:
pip install -e ".[dev]"Run tests:
pytestThis project is licensed under the MIT License - see the LICENSE file for details.
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>}
}