Last active
June 20, 2022 10:00
-
-
Save g-leech/a6172c29f12ea437d14d21172bb0e396 to your computer and use it in GitHub Desktop.
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "cold_takes_analysis.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/g-leech/a6172c29f12ea437d14d21172bb0e396/2022-06-16-sanity-checking-accuracy.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": { | |
"id": "3IU1XcPdplRI" | |
}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"asimov_url = \"https://docs.google.com/spreadsheets/d/e/2PACX-1vT6xk8FVWbA1U-0YRzTLf4FuBE2wo_WbOmN5m5LN4INELxe15BcAtL3slo7vRVCuvRTYReE2ZG92XUe/pub?gid=0&single=true&output=csv\"\n", | |
"clarke_url = \"https://docs.google.com/spreadsheets/d/e/2PACX-1vTQHFjeHPN-vnR8Ggmy8u8yJAYSJ4RO22QsNE0HZhjAyIwx6VNZ1qFM1wIVl9fxCTvQ5WNzLcRbN-j7/pub?gid=0&single=true&output=csv\"\n", | |
"heinlein_url = \"https://docs.google.com/spreadsheets/d/e/2PACX-1vRq-qcyqdbG-krcZmUXgpZLadDkpOSGjnqFGrp80pyk2kvdSR_2N5WTYcboksmuwhJsB_xxXX4pBZ6x/pub?gid=0&single=true&output=csv\"" | |
], | |
"metadata": { | |
"id": "ScEukCznpt-f" | |
}, | |
"execution_count": 20, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"asimov_df = pd.read_csv(asimov_url)\n", | |
"clarke_df = pd.read_csv(clarke_url)\n", | |
"heinlein_df = pd.read_csv(heinlein_url)" | |
], | |
"metadata": { | |
"id": "jBCQEaG7qFsU" | |
}, | |
"execution_count": 22, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"asimov_table = {}\n", | |
"\n", | |
"asimov = asimov_df[asimov_df[\"Resolved\"] == 1]\n", | |
"asimov = asimov[asimov[\"Years out\"] >= 30]\n", | |
"asimov_counts = asimov[\"Correctness\"].value_counts()\n", | |
"asimov_table[\"All predictions\"] = {\n", | |
" \"# correct\": asimov_counts[2],\n", | |
" \"# incorrect\": asimov_counts[0],\n", | |
" \"# ambiguous/near-miss\": asimov_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(asimov_counts[2] / (asimov_counts[2] + asimov_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"asimov = asimov_df[asimov_df[\"Resolved\"] == 1]\n", | |
"asimov = asimov[asimov[\"Years out\"] >= 30]\n", | |
"asimov = asimov[asimov[\"Category\"] == \"Tech\"]\n", | |
"asimov_counts = asimov[\"Correctness\"].value_counts()\n", | |
"asimov_table[\"Tech predictions\"] = {\n", | |
" \"# correct\": asimov_counts[2],\n", | |
" \"# incorrect\": asimov_counts[0],\n", | |
" \"# ambiguous/near-miss\": asimov_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(asimov_counts[2] / (asimov_counts[2] + asimov_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"asimov = asimov_df[asimov_df[\"Resolved\"] == 1]\n", | |
"asimov = asimov[asimov[\"Years out\"] >= 30]\n", | |
"asimov = asimov[asimov[\"Difficulty\"] >= 4]\n", | |
"asimov_counts = asimov[\"Correctness\"].value_counts()\n", | |
"asimov_table[\"Difficult predictions\"] = {\n", | |
" \"# correct\": asimov_counts[2],\n", | |
" \"# incorrect\": asimov_counts[0],\n", | |
" \"# ambiguous/near-miss\": asimov_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(asimov_counts[2] / (asimov_counts[2] + asimov_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"asimov = asimov_df[asimov_df[\"Resolved\"] == 1]\n", | |
"asimov = asimov[asimov[\"Years out\"] >= 30]\n", | |
"asimov = asimov[asimov[\"Category\"] == \"Tech\"]\n", | |
"asimov = asimov[asimov[\"Difficulty\"] >= 4]\n", | |
"asimov_counts = asimov[\"Correctness\"].value_counts()\n", | |
"asimov_table[\"Difficult tech predictions\"] = {\n", | |
" \"# correct\": asimov_counts[2],\n", | |
" \"# incorrect\": asimov_counts[0],\n", | |
" \"# ambiguous/near-miss\": asimov_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(asimov_counts[2] / (asimov_counts[2] + asimov_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"\n", | |
"asimov = asimov_df[asimov_df[\"Resolved\"] == 1]\n", | |
"asimov = asimov[asimov[\"Years out\"] >= 30]\n", | |
"asimov = asimov[asimov[\"Category\"] == \"Tech\"]\n", | |
"asimov = asimov[asimov[\"Difficulty\"] >= 4]\n", | |
"asimov = asimov[~asimov[\"Target Year\"].isna()] # Definite year: Target Year is not Nan\n", | |
"asimov_counts = asimov[\"Correctness\"].value_counts()\n", | |
"asimov_table[\"Difficult + tech + deinite date\"] = {\n", | |
" \"# correct\": asimov_counts[2],\n", | |
" \"# incorrect\": asimov_counts[0],\n", | |
" \"# ambiguous/near-miss\": asimov_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(asimov_counts[2] / (asimov_counts[2] + asimov_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"pd.DataFrame.from_dict(asimov_table).transpose()" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 206 | |
}, | |
"id": "vtl21xx9sATr", | |
"outputId": "5c27e7ac-ac02-428d-d316-7fbd66f7c4a9" | |
}, | |
"execution_count": 23, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
" # correct # incorrect \\\n", | |
"All predictions 23.0 29.0 \n", | |
"Tech predictions 11.0 4.0 \n", | |
"Difficult predictions 10.0 11.0 \n", | |
"Difficult tech predictions 5.0 1.0 \n", | |
"Difficult + tech + deinite date 5.0 1.0 \n", | |
"\n", | |
" # ambiguous/near-miss \\\n", | |
"All predictions 14.0 \n", | |
"Tech predictions 8.0 \n", | |
"Difficult predictions 7.0 \n", | |
"Difficult tech predictions 4.0 \n", | |
"Difficult + tech + deinite date 4.0 \n", | |
"\n", | |
" correct / (correct + incorrect) \n", | |
"All predictions 0.44 \n", | |
"Tech predictions 0.73 \n", | |
"Difficult predictions 0.48 \n", | |
"Difficult tech predictions 0.83 \n", | |
"Difficult + tech + deinite date 0.83 " | |
], | |
"text/html": [ | |
"\n", | |
" <div id=\"df-86761acd-f3b9-45d8-ba5b-1e55b12ea14f\">\n", | |
" <div class=\"colab-df-container\">\n", | |
" <div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th># correct</th>\n", | |
" <th># incorrect</th>\n", | |
" <th># ambiguous/near-miss</th>\n", | |
" <th>correct / (correct + incorrect)</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>All predictions</th>\n", | |
" <td>23.0</td>\n", | |
" <td>29.0</td>\n", | |
" <td>14.0</td>\n", | |
" <td>0.44</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Tech predictions</th>\n", | |
" <td>11.0</td>\n", | |
" <td>4.0</td>\n", | |
" <td>8.0</td>\n", | |
" <td>0.73</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult predictions</th>\n", | |
" <td>10.0</td>\n", | |
" <td>11.0</td>\n", | |
" <td>7.0</td>\n", | |
" <td>0.48</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult tech predictions</th>\n", | |
" <td>5.0</td>\n", | |
" <td>1.0</td>\n", | |
" <td>4.0</td>\n", | |
" <td>0.83</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult + tech + deinite date</th>\n", | |
" <td>5.0</td>\n", | |
" <td>1.0</td>\n", | |
" <td>4.0</td>\n", | |
" <td>0.83</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>\n", | |
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-86761acd-f3b9-45d8-ba5b-1e55b12ea14f')\"\n", | |
" title=\"Convert this dataframe to an interactive table.\"\n", | |
" style=\"display:none;\">\n", | |
" \n", | |
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n", | |
" width=\"24px\">\n", | |
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n", | |
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n", | |
" </svg>\n", | |
" </button>\n", | |
" \n", | |
" <style>\n", | |
" .colab-df-container {\n", | |
" display:flex;\n", | |
" flex-wrap:wrap;\n", | |
" gap: 12px;\n", | |
" }\n", | |
"\n", | |
" .colab-df-convert {\n", | |
" background-color: #E8F0FE;\n", | |
" border: none;\n", | |
" border-radius: 50%;\n", | |
" cursor: pointer;\n", | |
" display: none;\n", | |
" fill: #1967D2;\n", | |
" height: 32px;\n", | |
" padding: 0 0 0 0;\n", | |
" width: 32px;\n", | |
" }\n", | |
"\n", | |
" .colab-df-convert:hover {\n", | |
" background-color: #E2EBFA;\n", | |
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n", | |
" fill: #174EA6;\n", | |
" }\n", | |
"\n", | |
" [theme=dark] .colab-df-convert {\n", | |
" background-color: #3B4455;\n", | |
" fill: #D2E3FC;\n", | |
" }\n", | |
"\n", | |
" [theme=dark] .colab-df-convert:hover {\n", | |
" background-color: #434B5C;\n", | |
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n", | |
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n", | |
" fill: #FFFFFF;\n", | |
" }\n", | |
" </style>\n", | |
"\n", | |
" <script>\n", | |
" const buttonEl =\n", | |
" document.querySelector('#df-86761acd-f3b9-45d8-ba5b-1e55b12ea14f button.colab-df-convert');\n", | |
" buttonEl.style.display =\n", | |
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n", | |
"\n", | |
" async function convertToInteractive(key) {\n", | |
" const element = document.querySelector('#df-86761acd-f3b9-45d8-ba5b-1e55b12ea14f');\n", | |
" const dataTable =\n", | |
" await google.colab.kernel.invokeFunction('convertToInteractive',\n", | |
" [key], {});\n", | |
" if (!dataTable) return;\n", | |
"\n", | |
" const docLinkHtml = 'Like what you see? Visit the ' +\n", | |
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n", | |
" + ' to learn more about interactive tables.';\n", | |
" element.innerHTML = '';\n", | |
" dataTable['output_type'] = 'display_data';\n", | |
" await google.colab.output.renderOutput(dataTable, element);\n", | |
" const docLink = document.createElement('div');\n", | |
" docLink.innerHTML = docLinkHtml;\n", | |
" element.appendChild(docLink);\n", | |
" }\n", | |
" </script>\n", | |
" </div>\n", | |
" </div>\n", | |
" " | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 23 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"clarke_table = {}\n", | |
"\n", | |
"clarke = clarke_df[clarke_df[\"Resolved\"] == 1]\n", | |
"clarke = clarke[clarke[\"Years out\"] >= 30]\n", | |
"clarke_counts = clarke[\"Correctness\"].value_counts()\n", | |
"clarke_table[\"All predictions\"] = {\n", | |
" \"# correct\": clarke_counts[2],\n", | |
" \"# incorrect\": clarke_counts[0],\n", | |
" \"# ambiguous/near-miss\": clarke_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(clarke_counts[2] / (clarke_counts[2] + clarke_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"clarke = clarke_df[clarke_df[\"Resolved\"] == 1]\n", | |
"clarke = clarke[clarke[\"Years out\"] >= 30]\n", | |
"clarke = clarke[clarke[\"Category\"] == \"Tech\"]\n", | |
"clarke_counts = clarke[\"Correctness\"].value_counts()\n", | |
"clarke_table[\"Tech predictions\"] = {\n", | |
" \"# correct\": clarke_counts[2],\n", | |
" \"# incorrect\": clarke_counts[0],\n", | |
" \"# ambiguous/near-miss\": clarke_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(clarke_counts[2] / (clarke_counts[2] + clarke_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"clarke = clarke_df[clarke_df[\"Resolved\"] == 1]\n", | |
"clarke = clarke[clarke[\"Years out\"] >= 30]\n", | |
"clarke = clarke[clarke[\"Difficulty\"] >= 4]\n", | |
"clarke_counts = clarke[\"Correctness\"].value_counts()\n", | |
"clarke_table[\"Difficult predictions\"] = {\n", | |
" \"# correct\": clarke_counts[2],\n", | |
" \"# incorrect\": clarke_counts[0],\n", | |
" \"# ambiguous/near-miss\": clarke_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(clarke_counts[2] / (clarke_counts[2] + clarke_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"clarke = clarke_df[clarke_df[\"Resolved\"] == 1]\n", | |
"clarke = clarke[clarke[\"Years out\"] >= 30]\n", | |
"clarke = clarke[clarke[\"Category\"] == \"Tech\"]\n", | |
"clarke = clarke[clarke[\"Difficulty\"] >= 4]\n", | |
"clarke_counts = clarke[\"Correctness\"].value_counts()\n", | |
"clarke_table[\"Difficult tech predictions\"] = {\n", | |
" \"# correct\": clarke_counts[2],\n", | |
" \"# incorrect\": clarke_counts[0],\n", | |
" \"# ambiguous/near-miss\": clarke_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(clarke_counts[2] / (clarke_counts[2] + clarke_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"\n", | |
"clarke = clarke_df[clarke_df[\"Resolved\"] == 1]\n", | |
"clarke = clarke[clarke[\"Years out\"] >= 30]\n", | |
"clarke = clarke[clarke[\"Category\"] == \"Tech\"]\n", | |
"clarke = clarke[clarke[\"Difficulty\"] >= 4]\n", | |
"clarke = clarke[~clarke[\"Target Year\"].isna()] # Definite year: Target Year is not Nan\n", | |
"clarke_counts = clarke[\"Correctness\"].value_counts()\n", | |
"clarke_table[\"Difficult + tech + deinite date\"] = {\n", | |
" \"# correct\": clarke_counts[2],\n", | |
" \"# incorrect\": clarke_counts[0],\n", | |
" \"# ambiguous/near-miss\": clarke_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(clarke_counts[2] / (clarke_counts[2] + clarke_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"pd.DataFrame.from_dict(clarke_table).transpose()" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 206 | |
}, | |
"id": "XgU-STSrxRwz", | |
"outputId": "9bfe6188-65a9-48d3-b0a0-f3c1fdf07ba2" | |
}, | |
"execution_count": 24, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
" # correct # incorrect \\\n", | |
"All predictions 128.0 147.0 \n", | |
"Tech predictions 85.0 81.0 \n", | |
"Difficult predictions 14.0 10.0 \n", | |
"Difficult tech predictions 10.0 6.0 \n", | |
"Difficult + tech + deinite date 6.0 5.0 \n", | |
"\n", | |
" # ambiguous/near-miss \\\n", | |
"All predictions 48.0 \n", | |
"Tech predictions 29.0 \n", | |
"Difficult predictions 4.0 \n", | |
"Difficult tech predictions 2.0 \n", | |
"Difficult + tech + deinite date 2.0 \n", | |
"\n", | |
" correct / (correct + incorrect) \n", | |
"All predictions 0.47 \n", | |
"Tech predictions 0.51 \n", | |
"Difficult predictions 0.58 \n", | |
"Difficult tech predictions 0.62 \n", | |
"Difficult + tech + deinite date 0.55 " | |
], | |
"text/html": [ | |
"\n", | |
" <div id=\"df-ecd66f61-67bd-4f50-b3d1-3bbb7ce908f5\">\n", | |
" <div class=\"colab-df-container\">\n", | |
" <div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th># correct</th>\n", | |
" <th># incorrect</th>\n", | |
" <th># ambiguous/near-miss</th>\n", | |
" <th>correct / (correct + incorrect)</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>All predictions</th>\n", | |
" <td>128.0</td>\n", | |
" <td>147.0</td>\n", | |
" <td>48.0</td>\n", | |
" <td>0.47</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Tech predictions</th>\n", | |
" <td>85.0</td>\n", | |
" <td>81.0</td>\n", | |
" <td>29.0</td>\n", | |
" <td>0.51</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult predictions</th>\n", | |
" <td>14.0</td>\n", | |
" <td>10.0</td>\n", | |
" <td>4.0</td>\n", | |
" <td>0.58</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult tech predictions</th>\n", | |
" <td>10.0</td>\n", | |
" <td>6.0</td>\n", | |
" <td>2.0</td>\n", | |
" <td>0.62</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult + tech + deinite date</th>\n", | |
" <td>6.0</td>\n", | |
" <td>5.0</td>\n", | |
" <td>2.0</td>\n", | |
" <td>0.55</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>\n", | |
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-ecd66f61-67bd-4f50-b3d1-3bbb7ce908f5')\"\n", | |
" title=\"Convert this dataframe to an interactive table.\"\n", | |
" style=\"display:none;\">\n", | |
" \n", | |
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n", | |
" width=\"24px\">\n", | |
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n", | |
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n", | |
" </svg>\n", | |
" </button>\n", | |
" \n", | |
" <style>\n", | |
" .colab-df-container {\n", | |
" display:flex;\n", | |
" flex-wrap:wrap;\n", | |
" gap: 12px;\n", | |
" }\n", | |
"\n", | |
" .colab-df-convert {\n", | |
" background-color: #E8F0FE;\n", | |
" border: none;\n", | |
" border-radius: 50%;\n", | |
" cursor: pointer;\n", | |
" display: none;\n", | |
" fill: #1967D2;\n", | |
" height: 32px;\n", | |
" padding: 0 0 0 0;\n", | |
" width: 32px;\n", | |
" }\n", | |
"\n", | |
" .colab-df-convert:hover {\n", | |
" background-color: #E2EBFA;\n", | |
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n", | |
" fill: #174EA6;\n", | |
" }\n", | |
"\n", | |
" [theme=dark] .colab-df-convert {\n", | |
" background-color: #3B4455;\n", | |
" fill: #D2E3FC;\n", | |
" }\n", | |
"\n", | |
" [theme=dark] .colab-df-convert:hover {\n", | |
" background-color: #434B5C;\n", | |
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n", | |
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n", | |
" fill: #FFFFFF;\n", | |
" }\n", | |
" </style>\n", | |
"\n", | |
" <script>\n", | |
" const buttonEl =\n", | |
" document.querySelector('#df-ecd66f61-67bd-4f50-b3d1-3bbb7ce908f5 button.colab-df-convert');\n", | |
" buttonEl.style.display =\n", | |
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n", | |
"\n", | |
" async function convertToInteractive(key) {\n", | |
" const element = document.querySelector('#df-ecd66f61-67bd-4f50-b3d1-3bbb7ce908f5');\n", | |
" const dataTable =\n", | |
" await google.colab.kernel.invokeFunction('convertToInteractive',\n", | |
" [key], {});\n", | |
" if (!dataTable) return;\n", | |
"\n", | |
" const docLinkHtml = 'Like what you see? Visit the ' +\n", | |
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n", | |
" + ' to learn more about interactive tables.';\n", | |
" element.innerHTML = '';\n", | |
" dataTable['output_type'] = 'display_data';\n", | |
" await google.colab.output.renderOutput(dataTable, element);\n", | |
" const docLink = document.createElement('div');\n", | |
" docLink.innerHTML = docLinkHtml;\n", | |
" element.appendChild(docLink);\n", | |
" }\n", | |
" </script>\n", | |
" </div>\n", | |
" </div>\n", | |
" " | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 24 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"heinlein_table = {}\n", | |
"\n", | |
"heinlein = heinlein_df[heinlein_df[\"Resolved\"] == 1]\n", | |
"heinlein = heinlein[heinlein[\"Years out\"] >= 30]\n", | |
"heinlein_counts = heinlein[\"Correctness\"].value_counts()\n", | |
"heinlein_table[\"All predictions\"] = {\n", | |
" \"# correct\": heinlein_counts[2],\n", | |
" \"# incorrect\": heinlein_counts[0],\n", | |
" \"# ambiguous/near-miss\": heinlein_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(heinlein_counts[2] / (heinlein_counts[2] + heinlein_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"heinlein = heinlein_df[heinlein_df[\"Resolved\"] == 1]\n", | |
"heinlein = heinlein[heinlein[\"Years out\"] >= 30]\n", | |
"heinlein = heinlein[heinlein[\"Category\"] == \"Tech\"]\n", | |
"heinlein_counts = heinlein[\"Correctness\"].value_counts()\n", | |
"heinlein_table[\"Tech predictions\"] = {\n", | |
" \"# correct\": heinlein_counts[2],\n", | |
" \"# incorrect\": heinlein_counts[0],\n", | |
" \"# ambiguous/near-miss\": heinlein_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(heinlein_counts[2] / (heinlein_counts[2] + heinlein_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"heinlein = heinlein_df[heinlein_df[\"Resolved\"] == 1]\n", | |
"heinlein = heinlein[heinlein[\"Years out\"] >= 30]\n", | |
"heinlein = heinlein[heinlein[\"Difficulty\"] >= 4]\n", | |
"heinlein_counts = heinlein[\"Correctness\"].value_counts()\n", | |
"heinlein_table[\"Difficult predictions\"] = {\n", | |
" \"# correct\": heinlein_counts[2],\n", | |
" \"# incorrect\": heinlein_counts[0],\n", | |
" \"# ambiguous/near-miss\": heinlein_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(heinlein_counts[2] / (heinlein_counts[2] + heinlein_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"heinlein = heinlein_df[heinlein_df[\"Resolved\"] == 1]\n", | |
"heinlein = heinlein[heinlein[\"Years out\"] >= 30]\n", | |
"heinlein = heinlein[heinlein[\"Category\"] == \"Tech\"]\n", | |
"heinlein = heinlein[heinlein[\"Difficulty\"] >= 4]\n", | |
"heinlein_counts = heinlein[\"Correctness\"].value_counts()\n", | |
"heinlein_table[\"Difficult tech predictions\"] = {\n", | |
" \"# correct\": heinlein_counts[2],\n", | |
" \"# incorrect\": heinlein_counts[0],\n", | |
" \"# ambiguous/near-miss\": heinlein_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(heinlein_counts[2] / (heinlein_counts[2] + heinlein_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"\n", | |
"heinlein = heinlein_df[heinlein_df[\"Resolved\"] == 1]\n", | |
"heinlein = heinlein[heinlein[\"Years out\"] >= 30]\n", | |
"heinlein = heinlein[heinlein[\"Category\"] == \"Tech\"]\n", | |
"heinlein = heinlein[heinlein[\"Difficulty\"] >= 4]\n", | |
"heinlein = heinlein[~heinlein[\"Target Year\"].isna()] # Definite year: Target Year is not Nan\n", | |
"heinlein_counts = heinlein[\"Correctness\"].value_counts()\n", | |
"heinlein_table[\"Difficult + tech + deinite date\"] = {\n", | |
" \"# correct\": heinlein_counts.get(2, default=0),\n", | |
" \"# incorrect\": heinlein_counts[0],\n", | |
" \"# ambiguous/near-miss\": heinlein_counts[1],\n", | |
" \"correct / (correct + incorrect)\": round(heinlein_counts.get(2, default=0) / (heinlein_counts.get(2, default=0) + heinlein_counts[0]), 2)\n", | |
"}\n", | |
"\n", | |
"pd.DataFrame.from_dict(heinlein_table).transpose()" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 206 | |
}, | |
"id": "06ijKq9LtehL", | |
"outputId": "3e4edb7f-5c80-4e38-db20-a23a47602afd" | |
}, | |
"execution_count": 25, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
" # correct # incorrect \\\n", | |
"All predictions 19.0 41.0 \n", | |
"Tech predictions 14.0 20.0 \n", | |
"Difficult predictions 1.0 16.0 \n", | |
"Difficult tech predictions 1.0 9.0 \n", | |
"Difficult + tech + deinite date 0.0 1.0 \n", | |
"\n", | |
" # ambiguous/near-miss \\\n", | |
"All predictions 7.0 \n", | |
"Tech predictions 6.0 \n", | |
"Difficult predictions 1.0 \n", | |
"Difficult tech predictions 1.0 \n", | |
"Difficult + tech + deinite date 1.0 \n", | |
"\n", | |
" correct / (correct + incorrect) \n", | |
"All predictions 0.32 \n", | |
"Tech predictions 0.41 \n", | |
"Difficult predictions 0.06 \n", | |
"Difficult tech predictions 0.10 \n", | |
"Difficult + tech + deinite date 0.00 " | |
], | |
"text/html": [ | |
"\n", | |
" <div id=\"df-43605c16-0c44-430d-9a74-fac25b3259ae\">\n", | |
" <div class=\"colab-df-container\">\n", | |
" <div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th># correct</th>\n", | |
" <th># incorrect</th>\n", | |
" <th># ambiguous/near-miss</th>\n", | |
" <th>correct / (correct + incorrect)</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>All predictions</th>\n", | |
" <td>19.0</td>\n", | |
" <td>41.0</td>\n", | |
" <td>7.0</td>\n", | |
" <td>0.32</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Tech predictions</th>\n", | |
" <td>14.0</td>\n", | |
" <td>20.0</td>\n", | |
" <td>6.0</td>\n", | |
" <td>0.41</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult predictions</th>\n", | |
" <td>1.0</td>\n", | |
" <td>16.0</td>\n", | |
" <td>1.0</td>\n", | |
" <td>0.06</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult tech predictions</th>\n", | |
" <td>1.0</td>\n", | |
" <td>9.0</td>\n", | |
" <td>1.0</td>\n", | |
" <td>0.10</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>Difficult + tech + deinite date</th>\n", | |
" <td>0.0</td>\n", | |
" <td>1.0</td>\n", | |
" <td>1.0</td>\n", | |
" <td>0.00</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>\n", | |
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-43605c16-0c44-430d-9a74-fac25b3259ae')\"\n", | |
" title=\"Convert this dataframe to an interactive table.\"\n", | |
" style=\"display:none;\">\n", | |
" \n", | |
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n", | |
" width=\"24px\">\n", | |
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n", | |
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n", | |
" </svg>\n", | |
" </button>\n", | |
" \n", | |
" <style>\n", | |
" .colab-df-container {\n", | |
" display:flex;\n", | |
" flex-wrap:wrap;\n", | |
" gap: 12px;\n", | |
" }\n", | |
"\n", | |
" .colab-df-convert {\n", | |
" background-color: #E8F0FE;\n", | |
" border: none;\n", | |
" border-radius: 50%;\n", | |
" cursor: pointer;\n", | |
" display: none;\n", | |
" fill: #1967D2;\n", | |
" height: 32px;\n", | |
" padding: 0 0 0 0;\n", | |
" width: 32px;\n", | |
" }\n", | |
"\n", | |
" .colab-df-convert:hover {\n", | |
" background-color: #E2EBFA;\n", | |
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n", | |
" fill: #174EA6;\n", | |
" }\n", | |
"\n", | |
" [theme=dark] .colab-df-convert {\n", | |
" background-color: #3B4455;\n", | |
" fill: #D2E3FC;\n", | |
" }\n", | |
"\n", | |
" [theme=dark] .colab-df-convert:hover {\n", | |
" background-color: #434B5C;\n", | |
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n", | |
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n", | |
" fill: #FFFFFF;\n", | |
" }\n", | |
" </style>\n", | |
"\n", | |
" <script>\n", | |
" const buttonEl =\n", | |
" document.querySelector('#df-43605c16-0c44-430d-9a74-fac25b3259ae button.colab-df-convert');\n", | |
" buttonEl.style.display =\n", | |
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n", | |
"\n", | |
" async function convertToInteractive(key) {\n", | |
" const element = document.querySelector('#df-43605c16-0c44-430d-9a74-fac25b3259ae');\n", | |
" const dataTable =\n", | |
" await google.colab.kernel.invokeFunction('convertToInteractive',\n", | |
" [key], {});\n", | |
" if (!dataTable) return;\n", | |
"\n", | |
" const docLinkHtml = 'Like what you see? Visit the ' +\n", | |
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n", | |
" + ' to learn more about interactive tables.';\n", | |
" element.innerHTML = '';\n", | |
" dataTable['output_type'] = 'display_data';\n", | |
" await google.colab.output.renderOutput(dataTable, element);\n", | |
" const docLink = document.createElement('div');\n", | |
" docLink.innerHTML = docLinkHtml;\n", | |
" element.appendChild(docLink);\n", | |
" }\n", | |
" </script>\n", | |
" </div>\n", | |
" </div>\n", | |
" " | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 25 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment