Spaces:
Sleeping
Sleeping
fixes
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import pandas as pd
|
|
| 4 |
import os
|
| 5 |
import time
|
| 6 |
import datetime
|
| 7 |
-
from utils import fetch_competition_summary, fetch_models_evaluation, get_all_competition_summary, update_leader_info
|
| 8 |
# from dotenv import load_dotenv
|
| 9 |
from cfg import *
|
| 10 |
# load_dotenv()
|
|
@@ -69,8 +69,11 @@ def main():
|
|
| 69 |
st.session_state.leader_info[competition] = update_leader_info(st.session_state.leader_info, competition, best_model)
|
| 70 |
else:
|
| 71 |
st.session_state.leader_info[competition] = {
|
| 72 |
-
"Username": "N/A",
|
| 73 |
-
"
|
|
|
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
else:
|
| 76 |
competition_summaries, model_evaluations, _ = load_competition_data(st.session_state.last_update_time)
|
|
@@ -86,8 +89,8 @@ def main():
|
|
| 86 |
st.write("#### Select a competition to view more details and rankings.")
|
| 87 |
|
| 88 |
# Create a header for the table
|
| 89 |
-
cols = st.columns([1, 3, 2, 2, 2,
|
| 90 |
-
headers = ["Index", "Competition Name", "Leader", "
|
| 91 |
for col, header in zip(cols, headers):
|
| 92 |
col.write(header)
|
| 93 |
|
|
@@ -95,16 +98,15 @@ def main():
|
|
| 95 |
for index, (competition, details) in enumerate(COMPETITIONS.items(), start=1):
|
| 96 |
leader_info = st.session_state.get("leader_info", {}).get(competition, {})
|
| 97 |
|
| 98 |
-
cols = st.columns([1, 3, 2, 2, 2,
|
| 99 |
cols[0].write(index)
|
| 100 |
|
| 101 |
if cols[1].button(competition):
|
| 102 |
st.session_state.selected_competition = competition
|
| 103 |
cols[2].write(leader_info.get("Username", "N/A"))
|
| 104 |
-
cols[3].write(leader_info.get("
|
| 105 |
-
cols[4].write(leader_info.get("
|
| 106 |
-
cols[5].write(leader_info.get("
|
| 107 |
-
cols[6].write(leader_info.get("Days on Top", "N/A"))
|
| 108 |
if st.session_state.selected_competition:
|
| 109 |
competition_name = st.session_state.selected_competition
|
| 110 |
competition_details = COMPETITIONS.get(competition_name, {})
|
|
@@ -116,14 +118,14 @@ def main():
|
|
| 116 |
st.subheader("Competition Summary")
|
| 117 |
competition_summary_df = competition_summaries.get(competition_name, pd.DataFrame())
|
| 118 |
if not competition_summary_df.empty:
|
| 119 |
-
st.
|
| 120 |
else:
|
| 121 |
st.warning("No competition summary data available.")
|
| 122 |
|
| 123 |
st.subheader("Models Evaluation")
|
| 124 |
models_evaluation_df = model_evaluations.get(competition_name, pd.DataFrame())
|
| 125 |
if not models_evaluation_df.empty:
|
| 126 |
-
st.
|
| 127 |
else:
|
| 128 |
st.warning("No models evaluation data available.")
|
| 129 |
else:
|
|
|
|
| 4 |
import os
|
| 5 |
import time
|
| 6 |
import datetime
|
| 7 |
+
from utils import fetch_competition_summary, fetch_models_evaluation, get_all_competition_summary, update_leader_info, highlight_score_column
|
| 8 |
# from dotenv import load_dotenv
|
| 9 |
from cfg import *
|
| 10 |
# load_dotenv()
|
|
|
|
| 69 |
st.session_state.leader_info[competition] = update_leader_info(st.session_state.leader_info, competition, best_model)
|
| 70 |
else:
|
| 71 |
st.session_state.leader_info[competition] = {
|
| 72 |
+
"Username": "N/A",
|
| 73 |
+
"Hotkey": "N/A",
|
| 74 |
+
"Date": "N/A",
|
| 75 |
+
"UID": "N/A",
|
| 76 |
+
"Days on Top": "N/A"
|
| 77 |
}
|
| 78 |
else:
|
| 79 |
competition_summaries, model_evaluations, _ = load_competition_data(st.session_state.last_update_time)
|
|
|
|
| 89 |
st.write("#### Select a competition to view more details and rankings.")
|
| 90 |
|
| 91 |
# Create a header for the table
|
| 92 |
+
cols = st.columns([1, 3, 2, 2, 2, 1, 2])
|
| 93 |
+
headers = ["Index", "Competition Name", "Leader", "Date", "Hotkey", "Days on Top"]
|
| 94 |
for col, header in zip(cols, headers):
|
| 95 |
col.write(header)
|
| 96 |
|
|
|
|
| 98 |
for index, (competition, details) in enumerate(COMPETITIONS.items(), start=1):
|
| 99 |
leader_info = st.session_state.get("leader_info", {}).get(competition, {})
|
| 100 |
|
| 101 |
+
cols = st.columns([1, 3, 2, 2, 2, 1, 2])
|
| 102 |
cols[0].write(index)
|
| 103 |
|
| 104 |
if cols[1].button(competition):
|
| 105 |
st.session_state.selected_competition = competition
|
| 106 |
cols[2].write(leader_info.get("Username", "N/A"))
|
| 107 |
+
cols[3].write(leader_info.get("Date", "N/A"))
|
| 108 |
+
cols[4].write(leader_info.get("Hotkey", "N/A"))
|
| 109 |
+
cols[5].write(leader_info.get("Days on Top", "N/A"))
|
|
|
|
| 110 |
if st.session_state.selected_competition:
|
| 111 |
competition_name = st.session_state.selected_competition
|
| 112 |
competition_details = COMPETITIONS.get(competition_name, {})
|
|
|
|
| 118 |
st.subheader("Competition Summary")
|
| 119 |
competition_summary_df = competition_summaries.get(competition_name, pd.DataFrame())
|
| 120 |
if not competition_summary_df.empty:
|
| 121 |
+
st.dataframe(competition_summary_df, height=500)
|
| 122 |
else:
|
| 123 |
st.warning("No competition summary data available.")
|
| 124 |
|
| 125 |
st.subheader("Models Evaluation")
|
| 126 |
models_evaluation_df = model_evaluations.get(competition_name, pd.DataFrame())
|
| 127 |
if not models_evaluation_df.empty:
|
| 128 |
+
st.dataframe(models_evaluation_df.style.apply(highlight_score_column, axis=0))
|
| 129 |
else:
|
| 130 |
st.warning("No models evaluation data available.")
|
| 131 |
else:
|
utils.py
CHANGED
|
@@ -10,7 +10,6 @@ def update_leader_info(leader_info, competition, best_model):
|
|
| 10 |
if leader_info.get(competition) is None:
|
| 11 |
leader_info[competition] = {
|
| 12 |
"Username": best_model["Username"],
|
| 13 |
-
"Model Name": best_model["Model Name"],
|
| 14 |
"Hotkey": best_model["Hotkey"],
|
| 15 |
"Date": current_date,
|
| 16 |
"Days on Top": 1
|
|
@@ -21,7 +20,6 @@ def update_leader_info(leader_info, competition, best_model):
|
|
| 21 |
else:
|
| 22 |
leader_info[competition] = {
|
| 23 |
"Username": best_model["Username"],
|
| 24 |
-
"Model Name": best_model["Model Name"],
|
| 25 |
"Hotkey": best_model["Hotkey"],
|
| 26 |
"Date": current_date,
|
| 27 |
"Days on Top": 1
|
|
@@ -54,10 +52,10 @@ def fetch_competition_summary(api, projects, selected_project):
|
|
| 54 |
for run in runs:
|
| 55 |
try:
|
| 56 |
summary = run.summary
|
| 57 |
-
if summary.get("
|
| 58 |
data.append({
|
| 59 |
"ID": run.id,
|
| 60 |
-
"Validator ID": summary.get("
|
| 61 |
"Winning Hotkey": summary.get("winning_hotkey"),
|
| 62 |
"Run Time (s)": summary.get("run_time_s"),
|
| 63 |
"Created At": run.created_at,
|
|
@@ -83,18 +81,25 @@ def fetch_models_evaluation(api, projects, selected_project):
|
|
| 83 |
for run in runs:
|
| 84 |
try:
|
| 85 |
summary = run.summary
|
| 86 |
-
if summary.get("
|
| 87 |
data.append({
|
| 88 |
"ID": run.id,
|
| 89 |
"Username": run.user.username,
|
| 90 |
-
"
|
| 91 |
-
"Hotkey": summary.get("hotkey", "N/A"),
|
| 92 |
"Score": summary.get("score"),
|
| 93 |
-
|
|
|
|
| 94 |
"Accuracy": summary.get("accuracy"),
|
| 95 |
"Recall": summary.get("recall"),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
"ROC AUC": summary.get("roc_auc"),
|
|
|
|
|
|
|
| 97 |
"Created At": run.created_at,
|
|
|
|
| 98 |
})
|
| 99 |
except Exception as e:
|
| 100 |
st.write(f"Error processing run {run.id}: {str(e)}")
|
|
@@ -106,3 +111,8 @@ def fetch_models_evaluation(api, projects, selected_project):
|
|
| 106 |
|
| 107 |
return df
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
if leader_info.get(competition) is None:
|
| 11 |
leader_info[competition] = {
|
| 12 |
"Username": best_model["Username"],
|
|
|
|
| 13 |
"Hotkey": best_model["Hotkey"],
|
| 14 |
"Date": current_date,
|
| 15 |
"Days on Top": 1
|
|
|
|
| 20 |
else:
|
| 21 |
leader_info[competition] = {
|
| 22 |
"Username": best_model["Username"],
|
|
|
|
| 23 |
"Hotkey": best_model["Hotkey"],
|
| 24 |
"Date": current_date,
|
| 25 |
"Days on Top": 1
|
|
|
|
| 52 |
for run in runs:
|
| 53 |
try:
|
| 54 |
summary = run.summary
|
| 55 |
+
if summary.get("validator_hotkey") and summary.get("winning_hotkey"):
|
| 56 |
data.append({
|
| 57 |
"ID": run.id,
|
| 58 |
+
"Validator ID": summary.get("validator_hotkey"),
|
| 59 |
"Winning Hotkey": summary.get("winning_hotkey"),
|
| 60 |
"Run Time (s)": summary.get("run_time_s"),
|
| 61 |
"Created At": run.created_at,
|
|
|
|
| 81 |
for run in runs:
|
| 82 |
try:
|
| 83 |
summary = run.summary
|
| 84 |
+
if summary.get("score") is not None: # Assuming runs with score are model evaluations
|
| 85 |
data.append({
|
| 86 |
"ID": run.id,
|
| 87 |
"Username": run.user.username,
|
| 88 |
+
"Hotkey": summary.get("miner_hotkey", "N/A"),
|
|
|
|
| 89 |
"Score": summary.get("score"),
|
| 90 |
+
|
| 91 |
+
"F1-beta": summary.get("fbeta"),
|
| 92 |
"Accuracy": summary.get("accuracy"),
|
| 93 |
"Recall": summary.get("recall"),
|
| 94 |
+
"Precision": summary.get("precision"),
|
| 95 |
+
|
| 96 |
+
"Tested entries": summary.get("tested_entries"),
|
| 97 |
+
|
| 98 |
"ROC AUC": summary.get("roc_auc"),
|
| 99 |
+
"Confusion Matrix": summary.get("confusion_matrix"),
|
| 100 |
+
|
| 101 |
"Created At": run.created_at,
|
| 102 |
+
#TODO link to huggingface model
|
| 103 |
})
|
| 104 |
except Exception as e:
|
| 105 |
st.write(f"Error processing run {run.id}: {str(e)}")
|
|
|
|
| 111 |
|
| 112 |
return df
|
| 113 |
|
| 114 |
+
def highlight_score_column(s):
|
| 115 |
+
"""
|
| 116 |
+
Highlight the 'Score' column with a custom background color.
|
| 117 |
+
"""
|
| 118 |
+
return ['background-color: yellow' if s.name == 'Score' else '' for _ in s]
|