-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict.py
More file actions
29 lines (19 loc) · 815 Bytes
/
predict.py
File metadata and controls
29 lines (19 loc) · 815 Bytes
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
import os
import pickle
MODEL_PATH = os.path.join("saved_model", "email_classifier.pkl")
VECTORIZER_PATH = os.path.join("saved_model", "tfidf_vectorizer.pkl")
def load_pickle(path):
with open(path, "rb") as file:
return pickle.load(file)
def predict_email(subject, body):
model = load_pickle(MODEL_PATH)
vectorizer = load_pickle(VECTORIZER_PATH)
combined_text = f"{subject} {body}".strip()
text_vector = vectorizer.transform([combined_text])
prediction = model.predict(text_vector)[0]
return prediction
if __name__ == "__main__":
subject = "Interview invitation for Software Developer Intern"
body = "We would like to move you forward to the next stage. Please share your availability."
result = predict_email(subject, body)
print("Prediction:", result)