Waka Consulting Logo
Development case studyApplied Machine Learning

Developing a German-English Spam Classifier With Translation and Model Comparison

The German-English spam classifier turns a research pipeline into an interactive application that detects language, applies language-specific vectorizers and models, and compares native German predictions with translated English evaluation.

Featured projectDE/EN Spam Classifier
Repository-backed ML studyWAKA × DE/EN Spam Classifier
Approved outcome98.55% held-out accuracy
Pythonscikit-learnMarianMTStreamlit
Design focusNLP · Evaluation · Application
Dataset
3,790 emails
Held-out set
758 emails
Models
Three per language
Application
Streamlit
01 · Overview

An end-to-end classifier, not an isolated notebook result

The project trains separate German and English TF-IDF pipelines and compares Logistic Regression, Multinomial Naive Bayes, and Linear SVC. The stratified 80/20 split produces 3,032 training samples and 758 held-out test samples per language pipeline.

The application detects the input language. English messages run through the English model; German messages run through the native German model and can also be translated with MarianMT for comparison through the English pipeline. Saved vectorizers and classifiers make the evaluated workflow available to an interactive Streamlit interface.

ProductDE/EN Spam Classifier
PlatformMachine-learning web application
Development outcome98.55% held-out accuracy
02 · The challenge

Comparing cross-lingual behavior without hiding language-specific error patterns

A single accuracy number can conceal false positives, missed spam, translation effects, and class imbalance. The system needed consistent preprocessing, stratified evaluation, multiple model choices, and a visible separation between native-language and translated predictions.

01

Normalize URLs, email addresses, numbers, casing, and whitespace consistently.

02

Train independent German and English TF-IDF representations.

03

Compare interpretable classical models using spam-focused metrics.

04

Expose predictions and optional translation through a usable application.

03 · Engineering decisions

Engineering choices that shaped the system

The implementation favors a reproducible classical-ML baseline and explicit language paths before introducing more computationally expensive multilingual architectures.

01

Keep language-specific vectorizers

Independent German and English TF-IDF vocabularies preserve language-specific unigram and bigram signals instead of forcing both corpora into one feature space.

Language context matters
02

Evaluate three model families

Naive Bayes, balanced Logistic Regression, and balanced Linear SVC expose different precision and recall behavior on the same held-out split.

Compare tradeoffs, not just winners
03

Add translation as a comparison layer

German messages can be translated with MarianMT and evaluated by the English model without replacing the native German prediction.

Translation should remain visible
04

Package artifacts into an application

Cached vectorizers, trained models, language detection, translation, and probability handling are connected through Streamlit for real-time exploration.

A model needs an operating path
Approved outcome98.55% held-out accuracy
01Detect
02Normalize
03Classify
04Compare
Representative system visual. Dataset size, preprocessing, model choices, and evaluation results are taken from the inspected notebook, saved artifacts, application code, and project README.
04 · System workflow

A transparent multilingual prediction pipeline

Each step preserves enough context to interpret how the final classification was produced.

1

Detect

Identify the input language and choose the appropriate evaluation path.

2

Normalize

Mask URLs, addresses, and numbers before TF-IDF transformation.

3

Classify

Run the selected saved model and calculate available spam probability.

4

Compare

For German input, optionally inspect the translated English result beside the native prediction.

What the case demonstrates

A reproducible NLP pipeline with an interactive application

  • German and English preprocessing datasets
  • Separate TF-IDF vectorizers
  • Six saved classifier artifacts
  • Model evaluation notebook
  • Translation-assisted comparison pipeline
  • Streamlit prediction interface
05 · Outcome and evidence

98.55% accuracy on the held-out English test split

Balanced Logistic Regression achieved 98.55% accuracy on 758 held-out English samples, with 100% spam precision, 93.08% spam recall, and a 96.42% spam F1 score in the recorded notebook output.

98.55%Test accuracy

English Logistic Regression on 758 held-out samples

96.42%Spam F1

Recorded English Logistic Regression result

3,790Emails

Dataset size documented in the repository

English Logistic Regression: 599 true ham, 148 true spam, 11 missed spam

German Logistic Regression: 98.15% accuracy on the recorded held-out split

Model artifacts connected to a language-aware Streamlit workflow

06 · Key takeaways

What development teams can reuse from this work

  1. Accuracy must be read beside spam precision, recall, F1, and the confusion matrix.
  2. Native and translated predictions should remain distinguishable in cross-lingual systems.
  3. Classical TF-IDF models can provide a strong, interpretable baseline.
  4. Production email security would require drift monitoring, adversarial testing, privacy controls, and safe human review.
Questions

About the project and its evidence

What exactly achieved 98.55% accuracy?

Balanced Logistic Regression on the English TF-IDF pipeline achieved 98.55% accuracy across the notebook's 758-sample held-out test split.

Does that mean it will block 98.55% of all real spam?

No. The metric applies to the inspected dataset and split. Real-world performance can change with new languages, campaigns, domains, and adversarial behavior.

Why use translation as well as a German model?

Translation provides a comparison through the English pipeline while the native German model preserves language-specific features. The application keeps both paths visible.

Have a product idea?

Turn evaluated models into transparent, supportable applications.

Waka connects product thinking, interface design, development, and launch support in one delivery flow.

Plan a development project