Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add number of markets and resolution stats to the benchmark output #27

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions prediction_market_agent_tooling/benchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,30 @@ def get_markets_summary(self) -> t.Dict[str, t.List[str | float]]:
]
return markets_summary

def get_markets_results(self) -> dict[str, list[str | float]]:
return {
"Number of markets": [len(self.markets)],
"Proportion resolved": [
sum(1 for m in self.markets if m.is_resolved) / len(self.markets)
],
"Proportion YES": [
sum(
1
for m in self.markets
if m.probable_resolution == MarketResolution.YES
)
/ len(self.markets)
],
"Proportion NO": [
sum(
1
for m in self.markets
if m.probable_resolution == MarketResolution.NO
)
/ len(self.markets)
],
}

def calculate_expected_returns(
self, prediction: Prediction, market: Market
) -> float | None:
Expand Down Expand Up @@ -498,13 +522,17 @@ def compute_expected_returns_summary(

def generate_markdown_report(self) -> str:
md = "# Comparison Report\n\n"
md += "## Summary Statistics\n\n"
md += "## Market Results\n\n"
md += pd.DataFrame(self.get_markets_results()).to_markdown(index=False)
md += "\n\n"
md += "## Agent Results\n\n"
md += "### Summary Statistics\n\n"
md += pd.DataFrame(self.compute_metrics()).to_markdown(index=False)
md += "\n\n"
md += "## Markets\n\n"
md += "### Markets\n\n"
md += pd.DataFrame(self.get_markets_summary()).to_markdown(index=False)
md += "\n\n"
md += "## Expected value\n\n"
md += "### Expected value\n\n"
overall_summary, per_market = self.compute_expected_returns_summary()
md += pd.DataFrame(overall_summary).to_markdown(index=False)
md += "\n\n"
Expand Down
Loading