xinchen9 commited on
Commit
2b8ce29
1 Parent(s): 198f759

[Update]dummydatagen file and assets folder

Browse files
Files changed (2) hide show
  1. assets/uc_result.csv +6 -0
  2. dummydatagen.py +159 -0
assets/uc_result.csv ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ Method,Chruch,Parachute,Tench,Garbage Turch,Van Gogh,Violence,Illegal Activity,Nudity
2
+ ESD,98.58%,80.97%,93.96%,92.15%,55.78%,44.23%,65.55,6163,17.8
3
+ FMN,88.48%,56.77%,46.60%,45.64%,90.63%,73.46%,131.37,350,17.9
4
+ UCE,98.40%,60.22%,47.71%,94.31%,39.35%,34.67%,182.01,434,5.1
5
+ CA,60.82%,96.01%,92.70%,46.67%,90.11%,81.97%,54.21,734,10.1
6
+ SalUn,86.26%,90.39%,95.08%,86.91%,96.35%,99.59%,61.05,667,30.8
dummydatagen.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from datetime import datetime, timedelta
3
+ import numpy as np
4
+ import pandas as pd
5
+ import plotly.express as px
6
+ from plotly.graph_objs import Figure
7
+
8
+ # Dummy data creation
9
+
10
+
11
+ def dummy_data_for_plot(metrics, num_days=30):
12
+ dates = [datetime.now() - timedelta(days=i) for i in range(num_days)]
13
+ data = []
14
+
15
+ for metric in metrics:
16
+ for date in dates:
17
+ model = f"Model_{metric}"
18
+ score = np.random.uniform(50, 55)
19
+ data.append([date, metric, score, model])
20
+
21
+ df = pd.DataFrame(data, columns=["date", "task", "score", "model"])
22
+ return df
23
+
24
+
25
+ def create_metric_plot_obj_1(
26
+ df: pd.DataFrame, metrics: list[str], title: str
27
+ ) -> Figure:
28
+ """
29
+ Create a Plotly figure object with lines representing different metrics
30
+ and horizontal dotted lines representing human baselines.
31
+
32
+ :param df: The DataFrame containing the metric values, names, and dates.
33
+ :param metrics: A list of strings representing the names of the metrics
34
+ to be included in the plot.
35
+ :param title: A string representing the title of the plot.
36
+ :return: A Plotly figure object with lines representing metrics and
37
+ horizontal dotted lines representing human baselines.
38
+ """
39
+
40
+ # Filter the DataFrame based on the specified metrics
41
+ df = df[df["task"].isin(metrics)]
42
+
43
+ # Filter the human baselines based on the specified metrics
44
+ # filtered_human_baselines = {k: v for k, v in HUMAN_BASELINE.items() if k in metrics}
45
+
46
+ # Create a line figure using plotly express with specified markers and custom data
47
+ fig = px.line(
48
+ df,
49
+ x="date",
50
+ y="score",
51
+ color="task",
52
+ markers=True,
53
+ custom_data=["task", "score", "model"],
54
+ title=title,
55
+ )
56
+
57
+ # Update hovertemplate for better hover interaction experience
58
+ fig.update_traces(
59
+ hovertemplate="<br>".join(
60
+ [
61
+ "Model Name: %{customdata[2]}",
62
+ "Metric Name: %{customdata[0]}",
63
+ "Date: %{x}",
64
+ "Metric Value: %{y}",
65
+ ]
66
+ )
67
+ )
68
+
69
+ # Update the range of the y-axis
70
+ fig.update_layout(yaxis_range=[0, 100])
71
+
72
+ # Create a dictionary to hold the color mapping for each metric
73
+ metric_color_mapping = {}
74
+
75
+ # Map each metric name to its color in the figure
76
+ for trace in fig.data:
77
+ metric_color_mapping[trace.name] = trace.line.color
78
+
79
+ # Iterate over filtered human baselines and add horizontal lines to the figure
80
+ # for metric, value in filtered_human_baselines.items():
81
+ # color = metric_color_mapping.get(metric, "blue") # Retrieve color from mapping; default to blue if not found
82
+ # location = "top left" if metric == "HellaSwag" else "bottom left" # Set annotation position
83
+ # # Add horizontal line with matched color and positioned annotation
84
+ # fig.add_hline(
85
+ # y=value,
86
+ # line_dash="dot",
87
+ # annotation_text=f"{metric} human baseline",
88
+ # annotation_position=location,
89
+ # annotation_font_size=10,
90
+ # annotation_font_color=color,
91
+ # line_color=color,
92
+ # )
93
+
94
+ return fig
95
+
96
+
97
+ def dummydf():
98
+ # data = [{"Model": "gpt-35-turbo-1106",
99
+ # "Agent": "prompt agent",
100
+ # "Opponent Model": "gpt-4",
101
+ # "Opponent Agent": "prompt agent",
102
+ # 'Breakthrough': 0,
103
+ # 'Connect Four': 0,
104
+ # 'Blind Auction': 0,
105
+ # 'Kuhn Poker': 0,
106
+ # "Liar's Dice": 0,
107
+ # 'Negotiation': 0,
108
+ # 'Nim': 0,
109
+ # 'Pig': 0,
110
+ # 'Iterated Prisoners Dilemma': 0,
111
+ # 'Tic-Tac-Toe': 0
112
+ # },
113
+ # {"Model": "Llama-2-70b-chat-hf",
114
+ # "Agent": "prompt agent",
115
+ # "Opponent Model": "gpt-4",
116
+ # "Opponent Agent": "prompt agent",
117
+ # 'Breakthrough': 1,
118
+ # 'Connect Four': 0,
119
+ # 'Blind Auction': 0,
120
+ # 'Kuhn Poker': 0,
121
+ # "Liar's Dice": 0,
122
+ # 'Negotiation': 0,
123
+ # 'Nim': 0,
124
+ # 'Pig': 0,
125
+ # 'Iterated Prisoners Dilemma': 0,
126
+ # 'Tic-Tac-Toe': 0
127
+ # },
128
+ # {"Model": "gpt-35-turbo-1106",
129
+ # "Agent": "ToT agent",
130
+ # "Opponent Model": "gpt-4",
131
+ # "Opponent Agent": "prompt agent",
132
+ # 'Breakthrough': 0,
133
+ # 'Connect Four': 0,
134
+ # 'Blind Auction': 0,
135
+ # 'Kuhn Poker': 0,
136
+ # "Liar's Dice": 0,
137
+ # 'Negotiation': 0,
138
+ # 'Nim': 0,
139
+ # 'Pig': 0,
140
+ # 'Iterated Prisoners Dilemma': 0,
141
+ # 'Tic-Tac-Toe': 0
142
+ # },
143
+ # {"Model": "Llama-2-70b-chat-hf",
144
+ # "Agent": "CoT agent",
145
+ # "Opponent Model": "gpt-4",
146
+ # "Opponent Agent": "prompt agent",
147
+ # 'Breakthrough': 0,
148
+ # 'Connect Four': 0,
149
+ # 'Blind Auction': 0,
150
+ # 'Kuhn Poker': 0,
151
+ # "Liar's Dice": 0,
152
+ # 'Negotiation': 0,
153
+ # 'Nim': 0,
154
+ # 'Pig': 0,
155
+ # 'Iterated Prisoners Dilemma': 0,
156
+ # 'Tic-Tac-Toe': 0
157
+ # }]
158
+ df = pd.read_csv('./assets/uc_result.csv')
159
+ return df