Clean raw strings and tokenize them into word lists ready for feature extraction.
Split data, build a fixed vocabulary from training documents only, and convert tokenized text into bag-of-words count vectors.
Compute inverse document frequencies from the training BoW matrix and transform count vectors into TF-IDF feature matrices.
Implement sigmoid, probability prediction, binary cross-entropy with L2 penalty, and gradient computation.
Train weights with full-batch gradient descent and select the decision threshold that maximizes F1 on a validation set.
Compute confusion-matrix metrics, expose an end-to-end predict(text) API, and collect false positives vs false negatives for error analysis.