Corey Morris
commited on
Commit
•
c12bd84
1
Parent(s):
4dcdfc8
streamlit initial app
Browse files
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import os
|
4 |
+
import fnmatch
|
5 |
+
import json
|
6 |
+
|
7 |
+
class MultiURLData:
|
8 |
+
def __init__(self):
|
9 |
+
self.data = self.process_data()
|
10 |
+
|
11 |
+
def process_data(self):
|
12 |
+
dataframes = []
|
13 |
+
|
14 |
+
def find_files(directory, pattern):
|
15 |
+
for root, dirs, files in os.walk(directory):
|
16 |
+
for basename in files:
|
17 |
+
if fnmatch.fnmatch(basename, pattern):
|
18 |
+
filename = os.path.join(root, basename)
|
19 |
+
yield filename
|
20 |
+
|
21 |
+
for filename in find_files('results', 'results*.json'):
|
22 |
+
model_name = filename.split('/')[2]
|
23 |
+
with open(filename) as f:
|
24 |
+
data = json.load(f)
|
25 |
+
df = pd.DataFrame(data['results']).T
|
26 |
+
|
27 |
+
df = df.rename(columns={'acc': model_name})
|
28 |
+
|
29 |
+
df.index = df.index.str.replace('hendrycksTest-', '')
|
30 |
+
|
31 |
+
df.index = df.index.str.replace('harness\\|', '')
|
32 |
+
|
33 |
+
dataframes.append(df[[model_name]])
|
34 |
+
|
35 |
+
data = pd.concat(dataframes, axis=1)
|
36 |
+
|
37 |
+
data = data.transpose()
|
38 |
+
data['Model Name'] = data.index
|
39 |
+
cols = data.columns.tolist()
|
40 |
+
cols = cols[-1:] + cols[:-1]
|
41 |
+
data = data[cols]
|
42 |
+
|
43 |
+
return data
|
44 |
+
|
45 |
+
def get_data(self, selected_models):
|
46 |
+
filtered_data = self.data[self.data['Model Name'].isin(selected_models)]
|
47 |
+
return filtered_data
|
48 |
+
|
49 |
+
data_provider = MultiURLData()
|
50 |
+
|
51 |
+
# Create checkboxes for each column
|
52 |
+
selected_columns = st.multiselect(
|
53 |
+
'Select Columns',
|
54 |
+
data_provider.data.columns.tolist(),
|
55 |
+
default=data_provider.data.columns.tolist()
|
56 |
+
)
|
57 |
+
|
58 |
+
selected_models = st.multiselect(
|
59 |
+
'Select Models',
|
60 |
+
data_provider.data['Model Name'].tolist(),
|
61 |
+
default=data_provider.data['Model Name'].tolist()
|
62 |
+
)
|
63 |
+
|
64 |
+
|
65 |
+
# Get the filtered data and display it in a table
|
66 |
+
filtered_data = data_provider.get_data(selected_models)
|
67 |
+
st.dataframe(filtered_data)
|