-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
766 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n", | ||
"import seaborn as sns\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"# Define the range for the heatmap\n", | ||
"min_score = min(stories[\"log_score\"].min(), stories[\"predictions\"].min())\n", | ||
"max_score = max(stories[\"log_score\"].max(), stories[\"predictions\"].max())\n", | ||
"\n", | ||
"# Create a more continuous 2D histogram\n", | ||
"plt.figure(figsize=(12, 10))\n", | ||
"sns.kdeplot(\n", | ||
" data=stories.sample(10000, seed=42),\n", | ||
" x=\"log_score\",\n", | ||
" y=\"predictions\",\n", | ||
" cmap=\"YlOrRd\",\n", | ||
" fill=True,\n", | ||
" cbar=True,\n", | ||
" cbar_kws={\"label\": \"Density\"},\n", | ||
")\n", | ||
"\n", | ||
"plt.title(\"Density Heatmap of Predicted Score vs Actual Score\")\n", | ||
"plt.xlabel(\"Actual Score (log_score)\")\n", | ||
"plt.ylabel(\"Predicted Score\")\n", | ||
"\n", | ||
"# Set axis limits to match the data range\n", | ||
"plt.xlim(min_score, max_score)\n", | ||
"plt.ylim(min_score, max_score)\n", | ||
"\n", | ||
"# Add a diagonal line for reference\n", | ||
"plt.plot([min_score, max_score], [min_score, max_score], \"k--\", alpha=0.5)\n", | ||
"\n", | ||
"plt.tight_layout()\n", | ||
"plt.show()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |