cybersectony commited on
Commit
0236b92
1 Parent(s): 3a73780

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -1
README.md CHANGED
@@ -39,7 +39,36 @@ This model was trained using a [Phishing Email Detection Dataset](https://huggin
39
  **Usage Guide**
40
  **Installation**
41
 
42
- ```
43
  pip install transformers
44
  pip install torch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  ```
 
39
  **Usage Guide**
40
  **Installation**
41
 
42
+ ```bash
43
  pip install transformers
44
  pip install torch
45
+ ```
46
+
47
+ ```python
48
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
49
+ import torch
50
+
51
+ # Load model and tokenizer
52
+ tokenizer = AutoTokenizer.from_pretrained("your-username/model-name")
53
+ model = AutoModelForSequenceClassification.from_pretrained("your-username/model-name")
54
+
55
+ def predict_phishing(email_text):
56
+ # Preprocess and tokenize
57
+ inputs = tokenizer(email_text, return_tensors="pt", truncation=True, max_length=512)
58
+
59
+ # Get prediction
60
+ with torch.no_grad():
61
+ outputs = model(**inputs)
62
+ predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
63
+
64
+ return {
65
+ "is_phishing": bool(predictions[0][1] > 0.5),
66
+ "confidence": float(predictions[0][1])
67
+ }
68
+
69
+ # Example usage
70
+ email = "Your email text here..."
71
+ result = predict_phishing(email)
72
+ print(f"Is Phishing: {result['is_phishing']}")
73
+ print(f"Confidence: {result['confidence']:.2%}")
74
  ```