Views
No views yet
1 (empathetic) or 0 (not empathetic). The model is built on top of roberta-base using the simpletransformers library.AcnEmpathize_dataset.csv.[1.0, 3.0]) to aggressively counteract the heavy dataset imbalance.simpletransformers with the following hyperparameters to optimize minority class detection:FacebookAI/roberta-base[1.0, 3.0]simpletransformers library:1from simpletransformers.classification import ClassificationModel
2import numpy as np
3
4# Initialize the model
5model = ClassificationModel(
6 "roberta",
7 "dhyann2815/roberta-empathy-classifier",
8 use_cuda=False # Set to True if you have a GPU
9)
10
11# Define prediction function with confidence score
12def predict_empathy(text):
13 predictions, raw_outputs = model.predict([text])
14 logits = raw_outputs[0]
15 probabilities = np.exp(logits) / np.sum(np.exp(logits))
16 confidence = np.max(probabilities) * 100
17
18 status = "empathetic" if predictions[0] == 1 else "not empathetic"
19 return status, round(confidence, 2)
20
21# Run a prediction
22status, confidence = predict_empathy("I'm so sorry you're going through this, that sounds really difficult.")
23print(f"Prediction: {status} (Confidence: {confidence}%)")