Spaces:
Running
Running
File size: 2,210 Bytes
9806101 3f2dbd1 c7b6308 9806101 c7b6308 9806101 3f2dbd1 | 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 | def make_clickable_model(model_name, link=None):
if link:
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline; text-decoration-style: dotted;">{model_name}</a>'
return model_name
def format_score(value, decimals=2):
if value is None:
return "--"
return f"{value:.{decimals}f}"
def format_percentage(value, decimals=1, colored=True, inverted=False):
if value is None:
return "--"
pct = f"{value:.{decimals}f}%"
if not colored:
return pct
if inverted:
# lower is better (e.g. Bias, Hallucination)
if value <= 5:
color = "#4ade80"
elif value <= 15:
color = "#fbbf24"
else:
color = "#f87171"
else:
if value >= 75:
color = "#4ade80"
elif value >= 60:
color = "#fbbf24"
else:
color = "#f87171"
return f'<span style="color:{color};font-weight:600;">{pct}</span>'
def format_overall(value, decimals=1):
if value is None:
return "--"
pct = f"{value:.{decimals}f}%"
return f'<span class="overall-score">{pct}</span>'
def format_type_badge(type_str):
if type_str == "Open":
return '<span class="badge badge-open">Open</span>'
elif type_str == "Closed":
return '<span class="badge badge-closed">Closed</span>'
return type_str
# retained for backward compatibility with src/submission and src/populate
def model_hyperlink(link, model_name):
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
def styled_error(error):
return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
def styled_warning(warn):
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
def styled_message(message):
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
def has_no_nan_values(df, columns):
return df[columns].notna().all(axis=1)
def has_nan_values(df, columns):
return df[columns].isna().any(axis=1)
|