A comprehensive ensemble-based text classification system that distinguishes between human-written and AI-generated text with high accuracy. This implementation combines traditional machine learning (Logistic Regression, Random Forest, SVM, XGBoost) and deep learning approaches (BiLSTM with Attention, BERT) using advanced ensemble techniques.
Key Features:
6 diverse classifiers (4 traditional ML + 2 deep learning)
5,015-dimensional hybrid feature space (5,000 TF-IDF + 15 linguistic features)
Hybrid Feature Engineering: Combines vocabulary-based TF-IDF with linguistic style features
Multi-Paradigm Ensemble: Integrates linear models, tree ensembles, kernel methods, and neural networks
Optimized Weighting: Performance-based weight assignment for ensemble members
Balanced Performance: Equal precision and recall (99.59%) indicates no systematic bias
Domain Diversity: Trained across 5 different text domains for robust generalization
Feature Importance
Based on XGBoost analysis:
Feature Type
Importance
TF-IDF Features
89.2%
Average Sentence Length
4.3%
Lexical Diversity (TTR)
2.7%
Unique Words Ratio
1.5%
Average Word Length
1.1%
Others
1.2%
Insight: Vocabulary patterns dominate, but linguistic features provide crucial complementary information.
Limitations
Dataset Specificity: Trained on ChatGPT-generated text; may not generalize to other LLMs (GPT-4, Claude, Gemini)
Domain Dependency: Best performance on domains similar to training data
Temporal Drift: As LLMs evolve, detection patterns may become obsolete
Adversarial Vulnerability: Not evaluated against deliberate evasion attempts
Language: English-only (no multilingual support)
Computational Cost: Full ensemble requires running 6 models (mitigated by optimized weights)
Citation
If you use this model in your research, please cite:
bibtex
1@article{nasir2025humanaiclassifier,
2 title={Human vs. AI Text Classification: A Comprehensive Study Using Machine Learning and Deep Learning Approaches},
3 author={Nasir, Huzaifa},
4 institution={National University of Computer and Emerging Sciences, Pakistan},
5 year={2025},
6 note={Hugging Face: https://huggingface.co/huzaifanasirrr/human-vs-ai-text-classifier}
7}
HC3 Dataset:
bibtex
1@article{guo2023hc3,
2 title={How Close is ChatGPT to Human Experts? Comparison Corpus, Evaluation, and Detection},
3 author={Guo, Biyang and Zhang, Xin and Wang, Ziyuan and Jiang, Minqi and Nie, Jinran and Ding, Yuxuan and ... and Wu, Yupeng},
4 journal={arXiv preprint arXiv:2301.07597},
5 year={2023}
6}
Model Files
models/*.pkl - Traditional ML models (Logistic Regression, Random Forest, SVM, XGBoost)
models/bert_best.pt - Fine-tuned BERT model checkpoint
models/bilstm_best.h5 - BiLSTM with Attention model