forked from malusamayo/cmu-mlip-model-testing-lab
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathzenohub.py
31 lines (23 loc) · 1.06 KB
/
zenohub.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## If you don't have a Zeno account already, create one on Zeno Hub (https://hub.zenoml.com/signup).
## After logging in to Zeno Hub, generate your API key by clicking on your profile at the top right to navigate to your account page.
# !pip install zeno_client
from zeno_client import ZenoClient, ZenoMetric
import pandas as pd
df = pd.read_csv('tweets.csv')
df = df.reset_index()
# Initialize a client with the API key.
client = ZenoClient(API_KEY)
project = client.create_project(
name="Tweet Sentiment Analysis",
view="text-classification",
metrics=[
ZenoMetric(name="accuracy", type="mean", columns=["correct"]),
]
)
project.upload_dataset(df, id_column="index", data_column="text", label_column="label")
models = ['roberta', 'gpt2']
for model in models:
df_system = df[['index', model]]
# Measure accuracy for each instance, which is averaged by the ZenoMetric above
df_system["correct"] = (df_system[model] == df["label"]).astype(int)
project.upload_system(df_system, name=model, id_column="index", output_column=model)