Update app.py
Browse files
app.py
CHANGED
@@ -41,17 +41,15 @@ def load_leaderboard_data(csv_file_path):
|
|
41 |
df['pinned'] = False
|
42 |
df['selected'] = False
|
43 |
|
|
|
|
|
|
|
|
|
|
|
44 |
# Round numeric columns and handle NA values
|
45 |
numeric_columns = df.select_dtypes(include=[np.number]).columns
|
46 |
for col in numeric_columns:
|
47 |
-
df[col] = df[col].apply(lambda x:
|
48 |
-
|
49 |
-
# Handle Political Lean separately
|
50 |
-
df['Political Lean π'] = pd.to_numeric(df['Political Lean π'].str.rstrip('%'), errors='coerce')
|
51 |
-
df['Political Lean π'] = df['Political Lean π'].apply(lambda x: -999999 if pd.isna(x) else x)
|
52 |
-
|
53 |
-
# Convert the special value to None for display
|
54 |
-
df = df.replace({-999999: None})
|
55 |
|
56 |
return df
|
57 |
except Exception as e:
|
@@ -525,14 +523,29 @@ columnDefs = [
|
|
525 |
|
526 |
# Add axes columns with different widths
|
527 |
for i, col in enumerate(AXES_COLS_1):
|
528 |
-
col_def =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
if i == 0: # First column (govt)
|
530 |
-
col_def["cellClass"]
|
531 |
elif i == len(AXES_COLS_1) - 1: # Last column (scty)
|
532 |
-
col_def["cellClass"]
|
533 |
-
|
534 |
-
col_def["cellClass"] = ["ag-left-aligned-cell"]
|
535 |
columnDefs.append(col_def)
|
|
|
536 |
template_with_split_header = """
|
537 |
<div class="ag-cell-label-container" role="presentation">
|
538 |
<span ref="eMenu" class="ag-header-icon ag-header-cell-menu-button"></span>
|
@@ -559,20 +572,15 @@ for col in AXES_COLS_2:
|
|
559 |
"template": template_with_split_header.format(high=high, low=low)
|
560 |
},
|
561 |
"width": 175,
|
562 |
-
"sortable": True,
|
563 |
"filter": "agNumberColumnFilter",
|
564 |
"filterParams": {
|
565 |
"defaultOption": "inRange",
|
566 |
"filterOptions": ['equals', 'notEqual', 'greaterThan', 'greaterThanOrEqual', 'lessThan', 'lessThanOrEqual', 'inRange']
|
567 |
},
|
568 |
"valueFormatter": {
|
569 |
-
"function": ""
|
570 |
-
|
571 |
-
|
572 |
-
return d3.format('.1f')(params.value) + '%';
|
573 |
-
}
|
574 |
-
"""
|
575 |
-
}
|
576 |
})
|
577 |
|
578 |
# Date Columns
|
@@ -828,6 +836,12 @@ app.layout = html.Div([
|
|
828 |
html.Li("Scty: Higher = Progressive values, Lower = Traditional values")
|
829 |
], style={'marginTop': '0px', 'marginBottom': '16px'}),
|
830 |
|
|
|
|
|
|
|
|
|
|
|
|
|
831 |
html.Br(),
|
832 |
|
833 |
html.P("All local models are tested using Q6_K.gguf quants.")
|
|
|
41 |
df['pinned'] = False
|
42 |
df['selected'] = False
|
43 |
|
44 |
+
# Convert percentage strings to floats for all relevant columns
|
45 |
+
percentage_columns = ['Political Lean π'] + AXES_COLS_1 + AXES_COLS_2
|
46 |
+
for col in percentage_columns:
|
47 |
+
df[col] = pd.to_numeric(df[col].astype(str).str.rstrip('%'), errors='coerce')
|
48 |
+
|
49 |
# Round numeric columns and handle NA values
|
50 |
numeric_columns = df.select_dtypes(include=[np.number]).columns
|
51 |
for col in numeric_columns:
|
52 |
+
df[col] = df[col].apply(lambda x: None if pd.isna(x) else round(x, 3))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
return df
|
55 |
except Exception as e:
|
|
|
523 |
|
524 |
# Add axes columns with different widths
|
525 |
for i, col in enumerate(AXES_COLS_1):
|
526 |
+
col_def = {
|
527 |
+
"field": col,
|
528 |
+
"width": 105,
|
529 |
+
"filter": "agNumberColumnFilter",
|
530 |
+
"filterParams": {
|
531 |
+
"defaultOption": "inRange",
|
532 |
+
"filterOptions": ['equals', 'notEqual', 'greaterThan', 'greaterThanOrEqual', 'lessThan', 'lessThanOrEqual', 'inRange']
|
533 |
+
},
|
534 |
+
"valueFormatter": {
|
535 |
+
"function": "d3.format('.1f')(params.value) + '%'"
|
536 |
+
},
|
537 |
+
"headerClass": "ag-left-aligned-header wrap-text",
|
538 |
+
"cellClass": ["ag-left-aligned-cell"],
|
539 |
+
"sortingOrder": ['desc', 'asc']
|
540 |
+
}
|
541 |
+
|
542 |
if i == 0: # First column (govt)
|
543 |
+
col_def["cellClass"].append("border-left")
|
544 |
elif i == len(AXES_COLS_1) - 1: # Last column (scty)
|
545 |
+
col_def["cellClass"].append("border-right")
|
546 |
+
|
|
|
547 |
columnDefs.append(col_def)
|
548 |
+
|
549 |
template_with_split_header = """
|
550 |
<div class="ag-cell-label-container" role="presentation">
|
551 |
<span ref="eMenu" class="ag-header-icon ag-header-cell-menu-button"></span>
|
|
|
572 |
"template": template_with_split_header.format(high=high, low=low)
|
573 |
},
|
574 |
"width": 175,
|
|
|
575 |
"filter": "agNumberColumnFilter",
|
576 |
"filterParams": {
|
577 |
"defaultOption": "inRange",
|
578 |
"filterOptions": ['equals', 'notEqual', 'greaterThan', 'greaterThanOrEqual', 'lessThan', 'lessThanOrEqual', 'inRange']
|
579 |
},
|
580 |
"valueFormatter": {
|
581 |
+
"function": "d3.format('.1f')(params.value) + '%'"
|
582 |
+
},
|
583 |
+
"sortingOrder": ['desc', 'asc']
|
|
|
|
|
|
|
|
|
584 |
})
|
585 |
|
586 |
# Date Columns
|
|
|
836 |
html.Li("Scty: Higher = Progressive values, Lower = Traditional values")
|
837 |
], style={'marginTop': '0px', 'marginBottom': '16px'}),
|
838 |
|
839 |
+
html.P([
|
840 |
+
"For the 12 political axes, the percentage shown is how much the model aligns with the trait on the ",
|
841 |
+
html.U("left side of the hyphen"),
|
842 |
+
"."
|
843 |
+
]),
|
844 |
+
|
845 |
html.Br(),
|
846 |
|
847 |
html.P("All local models are tested using Q6_K.gguf quants.")
|