Metadata-Version: 2.4
Name: explain_ai_generated_text
Version: 0.1.1.1.7
Summary: A library to explain whether text is AI-generated or human-written using SHAP
Author-email: Shushanta Pudasaini <d23129142@mytublin.ie>
Keywords: AI,text-classification,explainability,SHAP
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: joblib
Requires-Dist: shap
Requires-Dist: xgboost
Requires-Dist: spacy
Requires-Dist: language-tool-python
Requires-Dist: textblob
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: scikit-learn
Requires-Dist: nltk
Requires-Dist: textstat
Requires-Dist: matplotlib
Requires-Dist: scipy
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"

# 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

```bash
pip install explain_ai_generated_text
```

Or install from source:

```bash
git clone <repository-url>
cd explain_ai_generated_text
pip install -e .
```

## Usage

```python
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:

```bash
pip install -e ".[dev]"
```

Run tests:

```bash
pytest
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Citation

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

```bibtex
@software{explain_ai_generated_text,
  title={Explainable AI Generated Text Detection},
  year={2025},
  url={<repository-url>}
}
```
