Text Classification in Python: M-Pesa Fraud Detection¶
Single-label text classification assigns exactly one label to each text. This page trains a fraud detector for mobile money (M-Pesa) SMS messages with JengaNLP.
Use when exactly one label is correct.
Dataset:
{"text": "Send your M-PESA PIN now", "label": 1}
{"text": "Your payment has been received", "label": 0}
Config:
tasks:
- name: mpesa_fraud_detection
type: single_label_classification
data_path: fixtures/sample_classification.jsonl
text_column: text
label_column: label
heads:
- name: fraud_head
num_labels: 2
Train:
Predict:
python -m jenga_nlp predict \
--config examples/configs/fixture_mpesa_fraud_cpu.yaml \
--model-dir /tmp/jenganlp_fixture_mpesa_fraud_cpu \
--task-name mpesa_fraud_detection \
--text "Share your PIN to reverse the transaction"
Next steps¶
- Configuration reference for every YAML option.
- Production inference to load the trained model once and serve predictions.
- All task types