Spaces:
Sleeping
Sleeping
File size: 5,068 Bytes
f7832ad 6322afe da95145 f7832ad 6322afe af3a32f 1e29694 af3a32f 1e29694 af3a32f 1e29694 af3a32f da95145 37341c1 da95145 c9c7736 f7832ad c2a3d61 da95145 f7832ad da95145 f7832ad da95145 f7832ad 6322afe da95145 1638e8f da95145 1638e8f da95145 c2a3d61 da95145 08f9ff1 c2a3d61 407badc 5cec38f 41411dc da95145 5cec38f 849cda1 45d786f da95145 5cec38f da95145 5cec38f da95145 1638e8f da95145 72dba71 79f11f0 72dba71 3cc1ef3 72dba71 3cc1ef3 72dba71 3cc1ef3 72dba71 3cc1ef3 72dba71 3cc1ef3 72dba71 3cc1ef3 72dba71 3cc1ef3 72dba71 | 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | import streamlit as st
import pandas as pd
import wandb
import datetime
def get_all_competition_summary(api, projects):
number_of_competitions = 0
number_of_runs = 0
for project in projects:
entity = projects[project]["entity"]
project_name = projects[project]["project"]
runs = api.runs(f"{entity}/{project_name}")
number_of_competitions += 1
number_of_runs += len(runs)
return number_of_competitions,number_of_runs
def fetch_competition_summary(api, projects, selected_project):
data = []
entity = projects[selected_project]["entity"]
project = projects[selected_project]["project"]
runs = api.runs(f"{entity}/{project}")
for run in runs:
try:
summary = run.summary
if summary.get("validator_hotkey") and summary.get("winning_hotkey"):
data.append({
"ID": run.id,
"Validator Hotkey": summary.get("validator_hotkey"),
"Winning Hotkey": summary.get("winning_hotkey"),
"Run Time (s)": summary.get("run_time_s"),
"Created At": run.created_at,
})
except Exception as e:
st.write(f"Error processing run {run.id}: {str(e)}")
df = pd.DataFrame(data)
if not df.empty:
df['Created At'] = pd.to_datetime(df['Created At'])
df = df.sort_values(by="Created At", ascending=False)
return df
def fetch_models_evaluation(api, projects, selected_project):
data = []
entity = projects[selected_project]["entity"]
project = projects[selected_project]["project"]
runs = api.runs(f"{entity}/{project}")
for run in runs:
try:
summary = run.summary
if summary.get("score") is not None: # Assuming runs with score are model evaluations
data.append({
"ID": run.id,
"Username": run.user.username,
"Hotkey": summary.get("miner_hotkey", "N/A"),
"Score": summary.get("score"),
"F1-beta": summary.get("fbeta"),
"Accuracy": summary.get("accuracy"),
"Recall": summary.get("recall"),
"Precision": summary.get("precision"),
"Tested entries": summary.get("tested_entries"),
# "Run Time (s)": summary.get("run_time_s"),
"ROC AUC": summary.get("roc_auc"),
"Confusion Matrix": summary.get("confusion_matrix"),
"Created At": run.created_at,
#TODO link to huggingface model
})
except Exception as e:
st.write(f"Error processing run {run.id}: {str(e)}")
df = pd.DataFrame(data)
if not df.empty:
df['Created At'] = pd.to_datetime(df['Created At'])
df = df.sort_values(by="Created At", ascending=False)
return df
def update_leader_info(leader_info, competition, best_model):
current_date = datetime.now().strftime("%Y-%m-%d")
if leader_info.get(competition) is None:
leader_info[competition] = {
"Username": best_model["Username"],
"Hotkey": best_model["Hotkey"],
"Date": current_date,
"Days on Top": 1
}
else:
if leader_info[competition]["UID"] == best_model["ID"]:
leader_info[competition]["Days on Top"] += 1
else:
leader_info[competition] = {
"Username": best_model["Username"],
"Hotkey": best_model["Hotkey"],
"Date": current_date,
"Days on Top": 1
}
return leader_info[competition]
def highlight_score_column(s):
"""
Highlight the 'Score' column with a custom background color.
"""
return ['background-color: yellow' if s.name == 'Score' else '' for _ in s]
def set_custom_table_style():
st.markdown("""
<style>
.dataframe, .summary-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
font-size: 16px;
min-width: 400px;
}
.dataframe th,
.dataframe td,
.summary-table th,
.summary-table td {
padding: 12px 15px;
border: 1px solid #CCCCCC;
text-align: left;
}
.dataframe thead th,
.summary-table th {
background-color: #333333;
color: #FFFFFF;
}
.dataframe tbody tr:nth-child(even),
.summary-table tr:nth-child(even) {
background-color: #F0F0F0;
}
.dataframe tbody tr:nth-child(odd),
.summary-table tr:nth-child(odd) {
background-color: #E0E0E0;
}
.dataframe tbody td,
.summary-table td {
color: #333333;
}
.dataframe tbody tr:hover,
.summary-table tr:hover {
background-color: #D1D1D1;
}
.table-container {
overflow-x: auto;
}
</style>
""", unsafe_allow_html=True)
|