|
from flask import url_for |
|
def df_to_table_html(df, additional_class=None): |
|
classes = 'table table-striped table-bordered' |
|
|
|
if additional_class is not None: |
|
classes += f" {additional_class}" |
|
|
|
|
|
descriptions = { |
|
"Ordinal - Win rate (β)": "Percentage of won games - a game is a comparison between each model pair, each metric, and each context pair (for stability) or context (for validity metrics).", |
|
"Cardinal - Score (β)": "Average score over all metrics (with descending metrics inverted), context pairs (for stability) and contexts ( for validity metrics).", |
|
"RO Stability (β)": "Correlation in the order of simulated participants (ordered based on the expression of the same values) over different contexts", |
|
"Stress (β)": "MDS fit of the observed value structure to the theoretical circular structure. Stress of 0 indicates 'perfect' fit, 0.025 excellent, 0.05 good, 0.1 fair, and 0.2 poor.", |
|
"Separability (β)": "Linear separability (in the 2D MDS space) of questions corresponding to different values (linear multi-label SVM classifier accuracy).", |
|
"CFI (β)": "Fit of the posited Magnifying glass CFA model (>.90 is considered acceptable fit).", |
|
"SRMR (β)": "Fit of the posited Magnifying glass CFA model (<.05 considered good fit and <.08 reasonable).", |
|
"RMSEA (β)": "Fit of the posited Magnifying glass CFA model (<.05 considered good fit and <.08 reasonable)." |
|
} |
|
|
|
|
|
|
|
html = df.to_html(classes=classes, escape=False, index=False) |
|
|
|
|
|
for metric, description in descriptions.items(): |
|
html = html.replace(f'>{metric}<', f' title="{description}">{metric}<') |
|
|
|
|
|
for model in df['Model']: |
|
model_link = f'<a href="{url_for("model_detail", model_name=model)}">{model}</a>' |
|
html = html.replace(f'>{model}<', f'>{model_link}<') |
|
|
|
return html |