File size: 619 Bytes
fe8b2b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pandas as pd
from sklearn.metrics import classification_report, accuracy_score

def evaluate_model(predict_func):
    try:
        df = pd.read_csv("data/eval_dataset.csv")

        texts = df["text"].astype(str).tolist()
        y_true = df["label"].str.capitalize().tolist()

        y_pred = predict_func(texts)

        report = classification_report(y_true, y_pred, output_dict=True)
        acc = accuracy_score(y_true, y_pred)

        return {
            "accuracy": round(acc, 3),
            "report": report
        }

    except Exception as e:
        return {
            "error": str(e)
        }