zsss0316 commited on
Commit
82a144f
·
verified ·
1 Parent(s): c504454

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +56 -105
index.html CHANGED
@@ -1,118 +1,69 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
- <title>Infernet Econometrics Benchmark Leaderboard</title>
 
 
 
6
  <style>
7
- body {font-family: Arial; max-width:1100px; margin:30px auto; padding:0 20px;}
8
- table {width:100%; border-collapse: collapse; margin:15px 0 40px;}
9
- th,td {border:1px solid #ccc; padding:10px; text-align:left;}
10
- th {background:#1f77b4; color:white;}
11
- .tab{margin:8px 4px;padding:8px 16px;border:1px solid #999;background:#eee;cursor:pointer;}
12
- .tab.active{background:#1f77b4;color:white;border-color:#1f77b4;}
13
- .panel{display:none;}
14
- .panel.show{display:block;}
15
  </style>
16
  </head>
17
  <body>
18
- <h1>🏆 Infernet Econometrics Benchmark Leaderboard</h1>
19
- <p><strong>CamoAiLab | HKU CAMO</strong><br>
20
- Dataset: <a href="https://huggingface.co/datasets/CamoAiLab/Infernet">CamoAiLab/Infernet</a>
21
- </p>
 
 
22
 
23
- <div>
24
- <button class="tab active" onclick="switchTab(0)">1. Compilation Success Rate</button>
25
- <button class="tab" onclick="switchTab(1)">2. Partial Replication Rate</button>
26
- <button class="tab" onclick="switchTab(2)">3. Correct Coefficient Direction</button>
27
- </div>
 
 
28
 
29
- <div class="panel show" id="panel-compile"></div>
30
- <div class="panel" id="panel-rep"></div>
31
- <div class="panel" id="panel-dir"></div>
 
32
 
33
- <h3>📌 Metric Definition</h3>
34
- <ul>
35
- <li><strong>Compilation Success:</strong> Generated code runs without runtime errors.</li>
36
- <li><strong>Partial Replication:</strong> Partially reproduce target estimation results.</li>
37
- <li><strong>Correct Coefficient Direction:</strong> Correct sign of estimated coefficients.</li>
38
- </ul>
 
 
 
39
 
40
- <script>
41
- const panels = document.querySelectorAll(".panel");
42
- const tabs = document.querySelectorAll(".tab");
43
- function switchTab(idx){
44
- panels.forEach(p=>p.classList.remove("show"));
45
- tabs.forEach(t=>t.classList.remove("active"));
46
- panels[idx].classList.add("show");
47
- tabs[idx].classList.add("active");
48
- }
 
 
 
 
49
 
50
- function parseCSV(text) {
51
- text = text.replace(/\r\n/g,"\n").replace(/\r/g,"\n");
52
- const lines = text.trim().split("\n").filter(line=>line.trim()!=='');
53
- const headers = lines[0].split(",").map(h=>h.trim());
54
- const rows = [];
55
- for(let i=1;i<lines.length;i++){
56
- const vals = lines[i].split(",").map(v=>v.trim());
57
- const obj = {};
58
- headers.forEach((h,idx)=>{
59
- obj[h] = vals[idx];
60
- });
61
- rows.push(obj);
62
- }
63
- return rows;
64
- }
65
 
66
- function buildTable(title, data, sortKey){
67
- const sorted = [...data].sort((a,b)=> Number(b[sortKey]) - Number(a[sortKey]));
68
- let html = `<h3>${title}</h3><table><tr><th>Rank</th><th>Model</th><th>${sortKey}</th></tr>`;
69
- sorted.forEach((row,i)=>{
70
- html += `<tr>
71
- <td>${i+1}</td>
72
- <td>${row["Model ID"]}</td>
73
- <td>${row[sortKey]}%</td>
74
- </tr>`;
75
- })
76
- html += "</table>";
77
- return html;
78
- }
79
-
80
- // 读取space本地csv,不再跨域访问dataset
81
- const csvUrl = "./results.csv";
82
-
83
- async function loadData(){
84
- try {
85
- const res = await fetch(csvUrl);
86
- if(!res.ok) throw new Error(`HTTP ${res.status}`);
87
- const csvText = await res.text();
88
- const data = parseCSV(csvText);
89
-
90
- if(data.length ===0){
91
- document.body.insertAdjacentHTML("beforeend",`<p style="color:red">Warning: CSV parsed zero rows</p>`);
92
- return;
93
- }
94
-
95
- document.getElementById("panel-compile").innerHTML = buildTable(
96
- "Ranked by Code Compilation Success",
97
- data,
98
- "Compilation Success (%)"
99
- );
100
- document.getElementById("panel-rep").innerHTML = buildTable(
101
- "Ranked by Partial Replication Rate",
102
- data,
103
- "Partial Replication (%)"
104
- );
105
- document.getElementById("panel-dir").innerHTML = buildTable(
106
- "Ranked by Correct Coefficient Direction",
107
- data,
108
- "Correct Coefficient Direction (%)"
109
- );
110
- } catch(err){
111
- console.error("load csv error",err);
112
- document.body.insertAdjacentHTML("beforeend",`<p style='color:red'>Failed to load ranking data: ${err.message}</p>`);
113
- }
114
- }
115
- loadData();
116
- </script>
117
  </body>
118
- </html>
 
1
+ <html>
 
2
  <head>
3
  <meta charset="UTF-8">
4
+ <title>Infernet Leaderboard</title>
5
+ <!-- 加载 Gradio-lite 引擎 -->
6
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
7
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
8
  <style>
9
+ body { background-color: #f9fafb; }
 
 
 
 
 
 
 
10
  </style>
11
  </head>
12
  <body>
13
+ <gradio-lite>
14
+ <!-- 这里编写您的 Python 代码 -->
15
+ <gradio-file name="app.py" entrypoint>
16
+ import gradio as gr
17
+ import pandas as pd
18
+ import io
19
 
20
+ # 1. 模拟数据(您也可以在此处直接修改数据 )
21
+ data_csv = """Model,Compilation %,Replication %,Direction %
22
+ Econometrics-Agent (Ours),92.5,88.0,85.0
23
+ GPT-4o,98.0,82.5,75.1
24
+ Claude 3.5 Sonnet,96.2,80.4,72.8
25
+ Llama-3-70B,85.0,65.0,60.5
26
+ """
27
 
28
+ def load_data():
29
+ df = pd.read_csv(io.StringIO(data_csv))
30
+ df["Overall Score"] = df[["Compilation %", "Replication %", "Direction %"]].mean(axis=1).round(2)
31
+ return df.sort_values("Overall Score", ascending=False)
32
 
33
+ # 2. 界面构建
34
+ with gr.Blocks(title="Infernet Leaderboard") as demo:
35
+ gr.HTML("<h1 style='text-align: center; color: #1f2937;'>🏆 Infernet Econometrics Leaderboard</h1>")
36
+ gr.HTML("<p style='text-align: center; color: #6b7280;'>CamoAiLab | Free Browser-based Edition</p>")
37
+
38
+ with gr.Row():
39
+ df_init = load_data()
40
+ gr.Number(label="Total Models", value=len(df_init), interactive=False)
41
+ gr.Number(label="Best Overall (%)", value=df_init["Overall Score"].max(), interactive=False)
42
 
43
+ gr.Markdown("---")
44
+
45
+ with gr.Tabs():
46
+ with gr.TabItem("📊 Leaderboard"):
47
+ search = gr.Textbox(placeholder="🔍 Search model...", label=None, show_label=False)
48
+ table = gr.Dataframe(value=df_init, interactive=False)
49
+
50
+ def filter_table(query):
51
+ full_df = load_data()
52
+ if not query: return full_df
53
+ return full_df[full_df["Model"].str.contains(query, case=False)]
54
+
55
+ search.change(fn=filter_table, inputs=search, outputs=table)
56
 
57
+ with gr.TabItem("📖 Definitions"):
58
+ gr.Markdown("""
59
+ ### 计量经济学评测指标
60
+ - **Compilation %**: 代码运行成功率。
61
+ - **Replication %**: 统计结果复现率。
62
+ - **Direction %**: **核心指标**。系数正负号正确率。
63
+ """)
 
 
 
 
 
 
 
 
64
 
65
+ demo.launch()
66
+ </gradio-file>
67
+ </gradio-lite>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  </body>
69
+ </html>