# %%
import pandas as pd
import gradio as gr
df = pd.read_csv("./data.csv")
def md_builder(model, dataset, displayed_metrics):
row = df[df["friendly_name"] == model]
str = (
f"## 🚧 Performance and safety of {model}
\n"
f"On dataset `{dataset}`\n"
)
if "Performance" in displayed_metrics:
str += f"\nPerformance: `{row['performance'].values[0]}`"
if "Accuracy" in displayed_metrics:
str += f"\nAccuracy: `{row['accuracy'].values[0]}`"
if "Precision" in displayed_metrics:
str += f"\nPrecision: `{row['precision_weighted'].values[0]}`"
if "Recall" in displayed_metrics:
str += f"\nRecall: `{row['recall_weighted'].values[0]}`"
if "Robustness" in displayed_metrics:
str += f"\nRobustness: `{100-row['robustness'].values[0]}`"
if "Fairness" in displayed_metrics:
str += f"\nFairness: `{0}`"
if "Failure Clusters" in displayed_metrics:
cl_count = row['cluster_count'].values[0]
str += f"\nTop failures:
(details for all {cl_count} clusters){row['top_failure_cluster'].values[0]}
(+{cl_count - 1} others)