Spaces:
Sleeping
Sleeping
Delete evaluate.py
Browse files- evaluate.py +0 -26
evaluate.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
|
| 2 |
-
from sklearn.metrics import classification_report
|
| 3 |
-
import tensorflow as tf
|
| 4 |
-
import pandas as pd
|
| 5 |
-
|
| 6 |
-
def get_classification_report():
|
| 7 |
-
try:
|
| 8 |
-
# Load test data
|
| 9 |
-
df = pd.read_csv("test.csv")
|
| 10 |
-
texts = df["text"].tolist()
|
| 11 |
-
true_labels = df["label"].tolist()
|
| 12 |
-
|
| 13 |
-
# Load tokenizer and model
|
| 14 |
-
tokenizer = AutoTokenizer.from_pretrained("shrish191/sentiment-bert")
|
| 15 |
-
model = TFAutoModelForSequenceClassification.from_pretrained("shrish191/sentiment-bert")
|
| 16 |
-
|
| 17 |
-
# Tokenize
|
| 18 |
-
inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="tf")
|
| 19 |
-
outputs = model(inputs)
|
| 20 |
-
preds = tf.math.argmax(outputs.logits, axis=1).numpy()
|
| 21 |
-
|
| 22 |
-
# Generate report
|
| 23 |
-
report = classification_report(true_labels, preds, target_names=["negative", "neutral", "positive"])
|
| 24 |
-
return report
|
| 25 |
-
except Exception as e:
|
| 26 |
-
return f"⚠️ Error occurred: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|