Downloads · 30 days
9
6% of all-time downloads
skgezhil2005/email_classifier
email_classifier is a machine learning model from skgezhil2005. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for keras. The card lists the license as apache-2.0.
This project implements an email classification model that assigns each email to a specific category using SBERT all-minilm-l6-v2 for text embeddings, followed by a sequential neural network for final classification.…
Downloads · 30 days
9
6% of all-time downloads
All-time downloads
141
Public
Repo size
3.3 MB
Likes
1
Public
Click a slice to open those files.
.keras3.2 MB · 96%
From the Hugging Face model README
This project implements an email classification model that assigns each email to a specific category using SBERT all-minilm-l6-v2 for text embeddings, followed by a sequential neural network for final classification.
SBERT (384‑d) → Dense(256, ReLU) → Dropout(0.4) → Dense(128, ReLU) → Dropout(0.4) → Softmax(5)[Academics, Clubs, Internships, Others, Talks]all‑MiniLM‑L6‑v2 (SBERT).The model was tested on 991 college‑email samples. Below are the per‑class precision, recall, F1‑score and support:
| Class | label | Support | Precision | Recall | F1‑Score |
|---|---|---|---|---|---|
| 0 | Academics | 200 | 0.92 | 0.97 | 0.94 |
| 1 | Clubs | 236 | 0.94 | 0.96 | 0.95 |
| 2 | Internships | 143 | 0.95 | 0.98 | 0.97 |
| 3 | Others | 200 | 0.95 | 0.83 | 0.89 |
| 4 | Takls | 212 | 0.93 | 0.94 | 0.93 |
Aggregate metrics
| Metric | Accuracy | Precision | Recall | F1‑Score |
|---|---|---|---|---|
| Overall | 0.94 | — | — | — |
| Macro avg | — | 0.94 | 0.94 | 0.94 |
| Weighted avg | — | 0.94 | 0.94 | 0.93 |

pip install tensorflow sentence-transformers huggingface_hub
from sentence_transformers import SentenceTransformer
import tensorflow as tf
from huggingface_hub import hf_hub_download
# 1) Load SBERT embedder
embedder = SentenceTransformer("all-MiniLM-L6-v2")
# 2) Load your fine‑tuned classifier
model_file = hf_hub_download(
repo_id="skgezhil2005/email_classifier",
filename="model_v2.keras" #replace with your model file
)
model = tf.keras.models.load_model(model_file)
# 3) Define label names (in the same order used during training)
labels = ["Academics", "Clubs", "Internships", "Others", "Talks"]
def classify_email(text: str) -> str:
# Compute a 1×384 SBERT embedding
emb = embedder.encode(text, convert_to_tensor=False)
emb = emb.reshape(1, -1)
# Predict probabilities and pick the highest‐scoring class
prediction = model.predict(emb)
pred_idx = int(np.argmax(prediction[0]))
return labels[pred_idx]