|
def get_classification_report(): |
|
from sklearn.metrics import classification_report |
|
import pandas as pd |
|
|
|
|
|
df = pd.read_csv("test.csv") |
|
texts = df["text"].tolist() |
|
true_labels = df["label"].tolist() |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("Shrish/mbert-sentiment") |
|
model = TFAutoModelForSequenceClassification.from_pretrained("Shrish/mbert-sentiment") |
|
|
|
|
|
inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="tf") |
|
outputs = model(inputs) |
|
predictions = tf.math.argmax(outputs.logits, axis=1).numpy() |
|
|
|
|
|
report = classification_report(true_labels, predictions, target_names=["negative", "neutral", "positive"]) |
|
return report |
|
|