Skip to content

Commit d4c4c4d

Browse files
committed
blog figures added
1 parent ff84d24 commit d4c4c4d

File tree

3 files changed

+766
-1
lines changed

3 files changed

+766
-1
lines changed

blog-figures.ipynb

Lines changed: 713 additions & 0 deletions
Large diffs are not rendered by default.

stories-inference.ipynb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import matplotlib.pyplot as plt\n",
10+
"import seaborn as sns\n",
11+
"import numpy as np\n",
12+
"\n",
13+
"# Define the range for the heatmap\n",
14+
"min_score = min(stories[\"log_score\"].min(), stories[\"predictions\"].min())\n",
15+
"max_score = max(stories[\"log_score\"].max(), stories[\"predictions\"].max())\n",
16+
"\n",
17+
"# Create a more continuous 2D histogram\n",
18+
"plt.figure(figsize=(12, 10))\n",
19+
"sns.kdeplot(\n",
20+
" data=stories.sample(10000, seed=42),\n",
21+
" x=\"log_score\",\n",
22+
" y=\"predictions\",\n",
23+
" cmap=\"YlOrRd\",\n",
24+
" fill=True,\n",
25+
" cbar=True,\n",
26+
" cbar_kws={\"label\": \"Density\"},\n",
27+
")\n",
28+
"\n",
29+
"plt.title(\"Density Heatmap of Predicted Score vs Actual Score\")\n",
30+
"plt.xlabel(\"Actual Score (log_score)\")\n",
31+
"plt.ylabel(\"Predicted Score\")\n",
32+
"\n",
33+
"# Set axis limits to match the data range\n",
34+
"plt.xlim(min_score, max_score)\n",
35+
"plt.ylim(min_score, max_score)\n",
36+
"\n",
37+
"# Add a diagonal line for reference\n",
38+
"plt.plot([min_score, max_score], [min_score, max_score], \"k--\", alpha=0.5)\n",
39+
"\n",
40+
"plt.tight_layout()\n",
41+
"plt.show()"
42+
]
43+
}
44+
],
45+
"metadata": {
46+
"language_info": {
47+
"name": "python"
48+
}
49+
},
50+
"nbformat": 4,
51+
"nbformat_minor": 2
52+
}

0 commit comments

Comments
 (0)