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.

- Dataset
- 3,790 emails
- Held-out set
- 758 emails
- Models
- Three per language
- Application
- Streamlit
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.
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.
Normalize URLs, email addresses, numbers, casing, and whitespace consistently.
Train independent German and English TF-IDF representations.
Compare interpretable classical models using spam-focused metrics.
Expose predictions and optional translation through a usable application.
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.
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 mattersEvaluate 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 winnersAdd 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 visiblePackage 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
A transparent multilingual prediction pipeline
Each step preserves enough context to interpret how the final classification was produced.
Detect
Identify the input language and choose the appropriate evaluation path.
Normalize
Mask URLs, addresses, and numbers before TF-IDF transformation.
Classify
Run the selected saved model and calculate available spam probability.
Compare
For German input, optionally inspect the translated English result beside the native prediction.
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
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.
English Logistic Regression on 758 held-out samples
Recorded English Logistic Regression result
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
What development teams can reuse from this work
- Accuracy must be read beside spam precision, recall, F1, and the confusion matrix.
- Native and translated predictions should remain distinguishable in cross-lingual systems.
- Classical TF-IDF models can provide a strong, interpretable baseline.
- Production email security would require drift monitoring, adversarial testing, privacy controls, and safe human review.
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.
Turn evaluated models into transparent, supportable applications.
Waka connects product thinking, interface design, development, and launch support in one delivery flow.