MCPcopy Create free account
hub / github.com/SalesforceAIResearch/perfcodegen / json2csv

Method json2csv

src/evaluate_prompt.py:1592–1612  ·  view source on GitHub ↗
(self, jsonfile)

Source from the content-addressed store, hash-verified

1590
1591
1592 def json2csv(self, jsonfile):
1593 results = json.load(open(jsonfile, "r"))
1594 lines = []
1595 for metric in results:
1596 lines.append(metric+ "+"*20)
1597 for dataset in results[metric]:
1598 lines.append(dataset + "="*10)
1599 for m in results[metric][dataset]:
1600 lines.append(m)
1601 lines.append("Strategy,Pass@1,Pass@5,Pass@8,Pass@10,Pass@20")
1602 for name in results[metric][dataset][m]:
1603 line = "{},{},{},{},{},{}".format(name,
1604 format(results[metric][dataset][m][name]["1"] * 100, ".2f"),
1605 format(results[metric][dataset][m][name]["5"] * 100, ".2f"),
1606 format(results[metric][dataset][m][name]["8"] * 100, ".2f"),
1607 format(results[metric][dataset][m][name]["10"] * 100, ".2f"),
1608 format(results[metric][dataset][m][name]["20"] * 100, ".2f"))
1609 lines.append(line)
1610
1611 with open(jsonfile.replace(".json", ".csv"), "w", encoding = "utf-8") as f:
1612 f.write("\n".join(lines))
1613
1614
1615 def json2csv2(self, jsonfile):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected