Text Classification
Scikit-learn
Joblib
Indonesian
English
phishing
tf-idf
logistic-regression
multilingual
security
Instructions to use Febriyansyah/phishing-email-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Febriyansyah/phishing-email-classifier with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Febriyansyah/phishing-email-classifier", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
File size: 3,887 Bytes
31dea96 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | ---
language:
- id
- en
tags:
- phishing
- text-classification
- tf-idf
- logistic-regression
- multilingual
- security
library_name: sklearn
pipeline_tag: text-classification
metrics:
- accuracy
- f1
license: mit
datasets:
- Febriyansyah/phishing-emails-multilingual
widget:
- text: "URGENT!! Confirm your bank details NOW or lose access: secure-login.updates.network/login"
---
# Phishing Email Classifier โ TF-IDF + Logistic Regression (ID/EN)
Model **ringan & CPU-friendly** untuk deteksi email phishing dwibahasa **Indonesia ๐ฎ๐ฉ & English ๐บ๐ธ** oleh [Febriyansyah](https://huggingface.co/Febriyansyah).
> โ ๏ธ **Synthetic & educational only** โ jangan gunakan untuk aktivitas ilegal. Dataset & model dibuat untuk riset defensive security.
## Arsitektur
```
Text โ TF-IDF char_wb (2โ4 gram, 39k max, sublinear) โ LogisticRegression (L2, liblinear, C=1.04)
```
- **Featurizer:** `hfhub.textfeat.Featurizer` โ `TfidfVectorizer(analyzer='char_wb', ngram_range=(2,4), max_features=39000, min_df=2, max_df=0.976, sublinear_tf=True)`
- **Classifier:** `LogisticRegression(C=1.04, solver='liblinear', max_iter=1700)`
- **Threshold operasional:** `0.488` (tuned, bukan 0.5) โ `prob โฅ 0.488 โ PHISHING`
- **Vocab aktual:** ~3.9k istilah (char_wb)
- **Payload:** `model.joblib` berisi `{featurizer, learner, gateway, decode, manifest}` โ lihat `metadata.json` untuk audit trail.
Dirancang tanpa dependensi berat (tanpa torch/transformers) โ inferensi <50ms di CPU, ideal untuk Spaces gratis & edge.
## Dataset Latih
[`Febriyansyah/phishing-emails-multilingual`](https://huggingface.co/datasets/Febriyansyah/phishing-emails-multilingual) โ **600 email sintetis** (300 phishing / 300 benign), seimbang ID/EN, digenerate via `scripts/build_phishing_dataset.py` (seed 2026). Split: 398 train / 202 validation (33.6% hold-out, seed 424242).
## Evaluasi (hold-out 202 sampel)
| Metric | Value |
|--------|-------|
| Accuracy | **1.0000** |
| Macro-F1 | **1.0000** |
| Confusion Matrix | `[[93, 0], [0, 109]]` (TN, FP / FN, TP) |
> Hasil sempurna mencerminkan sifat sintetis & pola yang jelas โ validasi di data real-world tetap diperlukan sebelum produksi.
## Penggunaan
### Python (lokal)
```bash
pip install scikit-learn numpy
python predict.py "URGENT: Verify your BCA account now at http://bca-secure.verify-center.cc/login"
# โ [PHISHING] prob=0.97 (threshold 0.488)
```
```python
import pickle
from pathlib import Path
payload = pickle.load(open("model.joblib","rb"))
featurizer, clf, thr = payload["featurizer"], payload["learner"], payload["gateway"]
proba = clf.predict_proba(featurizer.transform(["Hello, your invoice is ready"]))[0,1]
print("phishing" if proba >= thr else "benign", proba)
```
### Hugging Face
```python
from huggingface_hub import hf_hub_download
import pickle
p = hf_hub_download("Febriyansyah/phishing-email-classifier", filename="model.joblib")
payload = pickle.load(open(p,"rb"))
```
## Keterbatasan & Etika
- Data sintetis โ tidak mencakup semua variasi phishing dunia nyata (spear-phishing, BEC, dll).
- Bahasa terbatas ID/EN; performa di bahasa lain tidak terjamin.
- Guardrail: `edu-defense-only` โ gunakan hanya untuk edukasi & pertahanan.
## Space Demo
Coba langsung di ๐ค Space: [`Febriyansyah/phishing-scout`](https://huggingface.co/spaces/Febriyansyah/phishing-scout) (Gradio, CPU).
## Reproduksi
```bash
python scripts/build_phishing_dataset.py
python scripts/train_phishing_model.py --csv data/phishing_email/phishing_email_multilingual.csv --out models/phishing_model
```
## Lisensi
MIT โ lihat `LICENSE`.
## Citation
```bibtex
@misc{febriyansyah2026phishing,
author = {Febriyansyah},
title = {Phishing Email Classifier (TF-IDF + LogReg, ID/EN)},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/Febriyansyah/phishing-email-classifier}
}
```
|