Design Background

Leverages my 2,400-instance training set to train a statistical model locally on a desktop CPU in **less than 15 seconds**. It converts text into numerical embeddings using a lightweight library, meaning no fees, and maintaining data privacy.

Vectorization \& Extraction Stage

Instead of parsing grammar manually, we map the text to a semantic vector space. We use sentence-transformers, a highly optimized Python library that runs flawlessly on standard desktop CPUs.
  1. **Embedding Model Selection**: We utilize all-MiniLM-L6-v2. It is a compact Transformer model that converts any QuoteString into a fixed 384-dimensional floating-point array representing semantic meaning.
  2. **Feature Fusion**: We extract the NTEE category classification string (e.g., EduHigh, CommunityFoundation) and apply an algebraic \[\[One-Hot Encoding]{.underline}](https://en.wikipedia.org/wiki/One-hot) transformation to represent it as a sparse numeric vector.
  3. **Array Concatenation**: The 384 semantic dimensions and the categorical metadata dimensions are merged into a single multi-dimensional feature array ($X$).

Classification \& Fuzzy Engine Stage

Because the task maps down to structural text classification, **Logistic Regression with L2 Regularization (Ridge)** is mathematically ideal.

What is Logistic Regression

Logistic Regression with L2 Regularization (Ridge) **adds the sum of squared weights to the cost function**. This penalizes massive coefficients, preventing the model from over-relying on any single feature. It shrinks weights toward zero without eliminating them, stabilizing predictions and handling multicollinearity without dropping predictors.

Why Use L2 Regularization?

The Mathematical Formula

In standard logistic regression, the model seeks to minimize the **Log-Loss** (binary cross-entropy). With L2 regularization, the cost function J(θ) becomes:
$J(\\theta) = -\\frac{1}{m} \\sum\_{i=1}^{m} \[y^{(i)} \\log(h\_\\theta(x^{(i)})) + (1 - y^{(i)}) \\log(1 - h\_\\theta(x^{(i)}))] + \\lambda \\sum\_{j=1}^{n} \\theta\_j^2$
**Where:**

**How the Penalty Works**

Implementation in Python (Scikit-Learn)

In machine learning libraries like Scikit-learn , the class applies L2 regularization by default.

To dive deeper into the mathematical mechanics or learn how L2 interacts with other models, you can refer to tutorials covering Logistic Regression with L2 from Scratch or explore the Scikit-learn Ridge Coefficient examples.

All-MiniLM-L6-v2 Model Overview

The all-MiniLM-L6-v2 model is a sentence-transformers model designed to map sentences and paragraphs into a 384-dimensional dense vector space. It is primarily used for tasks such as semantic search, clustering, and sentence similarity. This model is lightweight and efficient, making it suitable for large-scale applications.

**Key Features**