pratyushmaini commited on
Commit
e62ba11
β€’
1 Parent(s): 9ff938b
Files changed (1) hide show
  1. app.py +27 -16
app.py CHANGED
@@ -3,7 +3,7 @@ import pandas as pd
3
  import matplotlib.pyplot as plt
4
 
5
  # Function to load data from a given CSV file
6
- def load_data(model,version):
7
  version = version.replace("%", "p")
8
  file_path = f'versions/{model}-{version}.csv' # Replace with your file paths
9
  df = pd.read_csv(file_path)
@@ -16,6 +16,14 @@ def load_data(model,version):
16
  "ROUGE Retain", "Truth Ratio Retain", "Prob. Retain",
17
  "ROUGE Forget", "Truth Ratio Forget", "Prob. Forget",
18
  ]
 
 
 
 
 
 
 
 
19
  #if there is a column with name WD, modify each entry in Method to include WD: method (WD = wd)
20
  if "WD" in df.columns:
21
  #get the WD column entry for each row and add it to the method name
@@ -30,6 +38,11 @@ def load_data(model,version):
30
 
31
  return df
32
 
 
 
 
 
 
33
  # Function for searching in the leaderboard
34
  def search_leaderboard(df, query):
35
  if query == "":
@@ -68,6 +81,11 @@ with demo:
68
  label="πŸ”„ Select Base Model",
69
  value="llama",
70
  )
 
 
 
 
 
71
 
72
  with gr.Row():
73
  search_bar = gr.Textbox(
@@ -83,36 +101,29 @@ with demo:
83
 
84
  version_dropdown.change(
85
  change_version,
86
- inputs=[model_dropdown,version_dropdown],
87
  outputs=leaderboard_table
88
  )
89
 
90
  model_dropdown.change(
91
  change_version,
92
- inputs=[model_dropdown,version_dropdown],
93
  outputs=leaderboard_table
94
  )
95
 
96
  search_bar.change(
97
  search_leaderboard,
98
- inputs=[leaderboard_table, search_bar],
99
  outputs=leaderboard_table
100
  )
101
 
102
- # with gr.TabItem("Plots"):
103
- # version_dropdown_plots = gr.Dropdown(
104
- # choices=["llama", "phi", "stable-lm"],
105
- # label="πŸ”„ Select Base Model",
106
- # value="llama",
107
- # )
108
 
109
- # with gr.Row():
110
- # methods_checkbox = gr.CheckboxGroup(
111
- # label="Select Methods",
112
- # choices=list(load_data("llama", "10%")['Method'].unique()), # To be populated dynamically
113
- # )
114
 
115
- # plot_output = gr.Plot()
116
 
117
  # # Dynamically update the choices for the methods checkbox
118
  # def update_method_choices(version):
 
3
  import matplotlib.pyplot as plt
4
 
5
  # Function to load data from a given CSV file
6
+ def load_data(model,version,metrics):
7
  version = version.replace("%", "p")
8
  file_path = f'versions/{model}-{version}.csv' # Replace with your file paths
9
  df = pd.read_csv(file_path)
 
16
  "ROUGE Retain", "Truth Ratio Retain", "Prob. Retain",
17
  "ROUGE Forget", "Truth Ratio Forget", "Prob. Forget",
18
  ]
19
+ #based on the metrics, remove the columns that are not needed
20
+ if "ROUGE" not in metrics:
21
+ column_names = [x for x in column_names if "ROUGE" not in x]
22
+ if "Truth Ratio" not in metrics:
23
+ column_names = [x for x in column_names if "Truth Ratio" not in x]
24
+ if "Prob." not in metrics:
25
+ column_names = [x for x in column_names if "Prob." not in x]
26
+
27
  #if there is a column with name WD, modify each entry in Method to include WD: method (WD = wd)
28
  if "WD" in df.columns:
29
  #get the WD column entry for each row and add it to the method name
 
38
 
39
  return df
40
 
41
+
42
+ # def style_leaderboard(df):
43
+ # make color red for background if column has "Forget" in it
44
+
45
+
46
  # Function for searching in the leaderboard
47
  def search_leaderboard(df, query):
48
  if query == "":
 
81
  label="πŸ”„ Select Base Model",
82
  value="llama",
83
  )
84
+ metrics_checkbox = gr.CheckboxGroup(
85
+ label="Select Metrics",
86
+ choices=["ROUGE", "Truth Ratio", "Prob."],
87
+ default=["ROUGE", "Truth Ratio", "Prob."],
88
+ )
89
 
90
  with gr.Row():
91
  search_bar = gr.Textbox(
 
101
 
102
  version_dropdown.change(
103
  change_version,
104
+ inputs=[model_dropdown,version_dropdown,metrics_checkbox],
105
  outputs=leaderboard_table
106
  )
107
 
108
  model_dropdown.change(
109
  change_version,
110
+ inputs=[model_dropdown,version_dropdown,metrics_checkbox],
111
  outputs=leaderboard_table
112
  )
113
 
114
  search_bar.change(
115
  search_leaderboard,
116
+ inputs=[leaderboard_table, search_bar,metrics_checkbox],
117
  outputs=leaderboard_table
118
  )
119
 
120
+ metrics_checkbox.change(
121
+ change_version,
122
+ inputs=[model_dropdown,version_dropdown,metrics_checkbox],
123
+ outputs=leaderboard_table
124
+ )
 
125
 
 
 
 
 
 
126
 
 
127
 
128
  # # Dynamically update the choices for the methods checkbox
129
  # def update_method_choices(version):