Quote Classifier via Vector Embedding
An offline, high-performance machine learning pipeline designed to parse scraped organizational text snippets, fuse them with structured CSV metadata, and classify them into validation categories using semantic vector embeddings.
Quick Start
Install Missing Dependencies
If not already installed, then:
```bash
pip install sentence-transformers scikit-learn numpy
```
Execute the complete training and verification pipeline:
```bash
python pipeline.py
```
Repository Architecture
The core of the software is divided into two structural execution files and an underlying class module:
`preprocess.py`: The data extraction layer. It handles directory scanning, cross-references website keys across text and CSV files, cleans raw punctuation boundaries, and fuses the raw content into a continuous, single-string tracking vector.
`pipeline.py`: The core execution engine. It coordinates the script lifecycle by running the data ingestion, training a localized regularized machine learning model, generating weights, and compiling the final analytics dashboard.
`checkquotes.py`: The model blueprint module. This houses the `EndowmentClassifierPipeline` class, which handles the underlying machine learning pipeline wrapper logic.
How the Ingestion Pipeline Works
The execution flow relies on a rigid directory layout structure to run successfully:
(Workspace Root)
│
├── FilterOuptut/ <-- Target directory containing metadata (.csv) files
├── TFquotes/ <-- Target directory containing raw text (.txt) files
│
├── preprocess.py <-- Automated data ingestion and text framing
├── pipeline.py <-- Core workflow script and output compiler
└── checkquotes.py <-- Embedded local machine learning model class
Feature Synthesis Fusing
To maximize semantic context, `preprocess.py` extracts raw items and compiles them sequentially into an explicit space-delimited text sequence rule layout:
`\\\\\\\[Organization Name] \\\\\\\[Cleaned Website Address] \\\\\\\[Cleaned Source URL] \\\\\\\[Verbatim Text Quote]`
Local Semantic Embeddings
The pipeline converts the compiled text string into a 384-dimensional floating-point semantic array on your local CPU using a lightweight, cached instance of the `all-MiniLM-L6-v2` Sentence Transformer.
Classification & Inference
The system trains a regularized Logistic Regression layer on the fused vector space. Candidate vectors are fed into a sigmoid function, outputting a continuous confidence profile between `0.0` and `1.0`. By default, scores $\ge 0.37$ are categorized as True (`T`) and scores $< 0.37$ are rejected as False (`F`).
Analytics & Reporting Output
Upon a successful execution run, the engine automatically compiles an `/Output` subdirectory containing deep-dive performance logs:
SummaryPerformanceReport.txt
A high-level validation metric snapshot detailing overall accuracy percentages alongside an explicit breakdown of True Positives, False Positives, True Negatives, and False Negatives.
Detailed Category Logs
(e.g., `EduHigh.txt`, `EduLow.txt`): Text-based breakdown matrices mapped back to your source categories. They provide alphabetical lookup tables for every evaluated domain, followed by a verbatim list of all target quotes stamped with their raw URL, ground truth, and exact NLP sigmoid confidence score.
The system was tested on 1,600 URLs from which the web scraper had identified 1,409 Best Quotes.
Those Best Quotes were manually evaluated by an expert as T or F.
The system vector embedding and logistic regression were generated off that information.
The SummaryPerformanceReport.txt is:
CLASSIFIER PERFORMANCE SUMMARY
Total Best Quotes Evaluated : 1409
Correct Classifications : 1330 (94.39%)
Operational Matrix Indices:
True Positives (T predicted as T) : 388
False Positives (F predicted as T) : 50
True Negatives (F predicted as F) : 942
False Negatives (T predicted as F) : 29
Precision Validation Metric : 88.58%
Recall Performance Metric : 93.05%