This project is a multi-signal research pipeline for studying false positives in AI-text detection — cases where human writing gets mislabeled as AI-generated.
The goal is not just to build another AI detector, but to analyze how and where commonly used AI-detection systems fail. The project stress-tests detector behavior across large sets of text chunks and uses statistical and feature-space analysis to study which measurable writing patterns are associated with misclassification.
The pipeline uses corpus processing, sentiment scoring, entropy/repetition features, structural-text features, n-gram Markov modeling, statistical testing, regression analysis, Bayesian analysis, PCA/clustering, detector-failure analysis, and generated plots.
The main question behind the project is:
When do AI-text detectors wrongly label human writing as AI-generated, and what measurable text-level signals appear around those false positives?
This matters because AI detectors are often used in academic and educational settings, where false positives can lead to human writers being wrongly accused of using AI.
SentimentPolarityAIDetection/
├── analysis.py # Main analysis script
├── bayesian_regression.py # Bayesian regression models
├── build_corpus_chunks.py # Corpus chunking from PMC XML
├── pmc_parser.py # PMC/JATS XML parser
├── regression_evidence.py # Regression analysis utilities
├── sentiment_regression_models.py # OLS regression models
├── statistical_tests_runner.py # Chi-square and statistical tests
├── corpus_chunks.csv # Chunked corpus data
├── corpus_with_results.csv # Full analysis results
├── detection_summary.csv # Detector-output summary
├── positive_detections.csv # Detector-positive classifications
├── chunk_index.json # Chunk indexing data
├── test_chunks.csv # Test dataset chunks
├── test_chunk_index.json # Test chunk indexing
├── top_bigrams.csv # Top bigram features
├── data_sample/ # Sample data
├── docs/ # Documentation
├── outputs/ # Generated outputs
├── plots/ # Generated visualizations
├── stats/ # Statistical outputs
│ ├── bayesian_*.csv # Bayesian analysis results
│ ├── chi_square_*.csv # Chi-square test results
│ ├── logit_*.csv # Logistic regression results
│ ├── ols_*.csv # OLS regression results
│ ├── model_metrics.csv # Model-performance metrics
│ └── sentiment_regression_*.csv # Sentiment-regression outputs
└── appendices/
├── APPENDIX_B_FULL_STATS.md # Full statistical results
├── CODE_MANIFEST.md # Reproducibility guide
├── CODEBOOK.md # Variable definitions
└── RESEARCH_INSTRUMENT.md # Research methodology
The project is organized around a reproducible analysis pipeline.
The pipeline processes PubMed Central articles and converts them into text chunks. Each chunk is indexed and stored with metadata so the analysis can be reproduced and inspected later.
For each text chunk, the project computes multiple writing signals, including:
- sentiment polarity
- entropy-based features
- repetition metrics
- structural-text features
- lexical features
- n-gram patterns
- Markov-style transition patterns
- detector probability outputs
These signals are used to compare human and AI-generated writing and to study detector behavior.
The project applies AI-detection models to large sets of text chunks and records detector outputs, confidence scores, and positive classifications.
The main focus is on false positives: cases where human-authored writing is flagged as AI-generated.
The project uses statistical testing and modeling to study relationships between text-level features and detector classifications.
This includes:
- chi-square tests
- OLS regression
- logistic regression
- Bayesian regression
- model-performance summaries
- regression diagnostics
The project uses PCA, clustering, feature analysis, and generated visualizations to inspect whether false-positive cases form recognizable patterns in feature space.
The goal is to better characterize when detector outputs should not be trusted.
The project uses Python and the following packages:
- pandas
- numpy
- nltk
- torch
- transformers
- scipy
- matplotlib
- tqdm
Install dependencies:
pip install pandas numpy nltk torch transformers scipy matplotlib tqdmDownload required NLTK data:
python -c "import nltk; nltk.download('vader_lexicon'); nltk.download('punkt')"Place raw PMC XML files in:
data/raw/PMC/
Then build the chunked corpus:
python build_corpus_chunks.py --pmc-dir ../data/raw/PMC --out corpus_chunks.csv --sentences-per-chunk 8This creates corpus_chunks.csv, which contains chunked text data and metadata.
Expected columns include:
pmcidtitleabstractchunk_idchunk_textword_countsentence_count
Run the main pipeline:
python analysis.py corpus_chunks.csvThe script:
- loads corpus chunks
- computes text-level features
- calculates sentiment scores
- applies AI-detection models
- records detector outputs
- saves checkpoints
- generates statistical outputs and plots
Primary output:
corpus_with_results.csv
Run chi-square tests:
python statistical_tests_runner.pyGenerated files include:
stats/chi_square_contingency.csvstats/chi_square_expected.csvstats/chi_square_stats.csvdetection_summary.csv
Run regression models:
python sentiment_regression_models.pyGenerated files include:
stats/ols_coefficients.csvstats/ols_summary.txtstats/sentiment_regression_vif.csv
Run Bayesian analysis:
python bayesian_regression.pyBayesian posterior estimates and probability summaries are saved in the stats/ directory.
Main outputs include:
corpus_chunks.csv— chunked input corpuscorpus_with_results.csv— complete feature and detector-output tabledetection_summary.csv— detector behavior summarypositive_detections.csv— chunks flagged as AI-generatedstats/— statistical outputsplots/— generated visualizationsappendices/— methodology, codebook, and reproducibility documentation
The project includes:
- chunk indexes
- checkpointed processing
- saved intermediate outputs
- documented statistical results
- a code manifest
- a codebook
- a research methodology document
These files are intended to make the analysis easier to inspect, rerun, and extend.
This project does not claim to solve AI-text detection. Detector behavior depends on the dataset, model, text length, writing domain, thresholds, and preprocessing choices.
The project should be read as an empirical analysis of detector reliability and false-positive behavior under the tested conditions.
This project is released under the MIT License.
For questions or issues, please open an issue on the repository.