From a5d556ce35b592fdf833e9d4fb36746c30015117 Mon Sep 17 00:00:00 2001 From: Simon Koch-Sultan Date: Mon, 16 Nov 2026 16:06:04 -0500 Subject: [PATCH] [DOCS] Show the link ratios in use in "Discarding Problematic Link Ratios" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each example in this section of the development tutorial now calls fit_transform on genins and shows age_to_age, which leaves the dropped link ratios blank, and then shows ldf_ in a new cell. Before, each example showed only ldf_, so a reader could not see which ratios a setting removed. One sentence in the section intro says what the two tables show. Closes #1631. Developed with an AI assistant (Árbol, running Muse). --- .../tutorials/development-tutorial.ipynb | 2243 ++++++++++++----- 1 file changed, 1665 insertions(+), 578 deletions(-) diff --git a/docs/getting_started/tutorials/development-tutorial.ipynb b/docs/getting_started/tutorials/development-tutorial.ipynb index 6b0dd0952..b3c7592ad 100644 --- a/docs/getting_started/tutorials/development-tutorial.ipynb +++ b/docs/getting_started/tutorials/development-tutorial.ipynb @@ -12,6 +12,7 @@ }, { "cell_type": "code", + "execution_count": 1, "id": "402551b2", "metadata": { "ExecuteTime": { @@ -19,16 +20,6 @@ "start_time": "2026-01-28T04:15:10.637444Z" } }, - "source": [ - "import numpy as np\n", - "import pandas as pd\n", - "\n", - "import chainladder as cl\n", - "\n", - "print(\"pandas: \" + pd.__version__)\n", - "print(\"numpy: \" + np.__version__)\n", - "print(\"chainladder: \" + cl.__version__)" - ], "outputs": [ { "name": "stdout", @@ -40,7 +31,16 @@ ] } ], - "execution_count": 1 + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "\n", + "import chainladder as cl\n", + "\n", + "print(\"pandas: \" + pd.__version__)\n", + "print(\"numpy: \" + np.__version__)\n", + "print(\"chainladder: \" + cl.__version__)" + ] }, { "cell_type": "markdown", @@ -80,6 +80,7 @@ }, { "cell_type": "code", + "execution_count": 2, "id": "3e4d1a0f", "metadata": { "ExecuteTime": { @@ -87,17 +88,6 @@ "start_time": "2026-01-28T04:15:11.672865Z" } }, - "source": [ - "raa = cl.load_sample(\"raa\")\n", - "print(\n", - " \"Are valuation years correlated? Or, are the origins correlated?\",\n", - " raa.valuation_correlation(p_critical=0.1, total=True).z_critical.values,\n", - ")\n", - "print(\n", - " \"Are development periods coorelated?\",\n", - " raa.development_correlation(p_critical=0.5).t_critical.values,\n", - ")" - ], "outputs": [ { "name": "stdout", @@ -108,7 +98,17 @@ ] } ], - "execution_count": 2 + "source": [ + "raa = cl.load_sample(\"raa\")\n", + "print(\n", + " \"Are valuation years correlated? Or, are the origins correlated?\",\n", + " raa.valuation_correlation(p_critical=0.1, total=True).z_critical.values,\n", + ")\n", + "print(\n", + " \"Are development periods coorelated?\",\n", + " raa.development_correlation(p_critical=0.5).t_critical.values,\n", + ")" + ] }, { "cell_type": "markdown", @@ -122,6 +122,7 @@ }, { "cell_type": "code", + "execution_count": 3, "id": "c7d62755", "metadata": { "ExecuteTime": { @@ -129,16 +130,9 @@ "start_time": "2026-01-28T04:15:11.782922Z" } }, - "source": [ - "raa.valuation_correlation(p_critical=0.1, total=False).z_critical" - ], "outputs": [ { "data": { - "text/plain": [ - " 1982 1983 1984 1985 1986 1987 1988 1989 1990\n", - "1981 False False False False False False False False False" - ], "text/html": [ "\n", " \n", @@ -170,6 +164,10 @@ " \n", " \n", "
" + ], + "text/plain": [ + " 1982 1983 1984 1985 1986 1987 1988 1989 1990\n", + "1981 False False False False False False False False False" ] }, "execution_count": 3, @@ -177,7 +175,9 @@ "output_type": "execute_result" } ], - "execution_count": 3 + "source": [ + "raa.valuation_correlation(p_critical=0.1, total=False).z_critical" + ] }, { "cell_type": "markdown", @@ -211,6 +211,7 @@ }, { "cell_type": "code", + "execution_count": 4, "id": "e12aa974", "metadata": { "ExecuteTime": { @@ -218,12 +219,11 @@ "start_time": "2026-01-28T04:15:11.884836Z" } }, + "outputs": [], "source": [ "genins = cl.load_sample(\"genins\")\n", "dev = cl.Development().fit(genins)" - ], - "outputs": [], - "execution_count": 4 + ] }, { "cell_type": "markdown", @@ -236,6 +236,7 @@ }, { "cell_type": "code", + "execution_count": 5, "id": "d5a96406", "metadata": { "ExecuteTime": { @@ -243,16 +244,9 @@ "start_time": "2026-01-28T04:15:11.967711Z" } }, - "source": [ - "dev.ldf_" - ], "outputs": [ { "data": { - "text/plain": [ - " 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120\n", - "(All) 3.490607 1.747333 1.457413 1.173852 1.103824 1.086269 1.053874 1.076555 1.017725" - ], "text/html": [ "\n", " \n", @@ -284,6 +278,10 @@ " \n", " \n", "
" + ], + "text/plain": [ + " 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120\n", + "(All) 3.490607 1.747333 1.457413 1.173852 1.103824 1.086269 1.053874 1.076555 1.017725" ] }, "execution_count": 5, @@ -291,7 +289,9 @@ "output_type": "execute_result" } ], - "execution_count": 5 + "source": [ + "dev.ldf_" + ] }, { "cell_type": "markdown", @@ -303,6 +303,7 @@ }, { "cell_type": "code", + "execution_count": 6, "id": "221819d6", "metadata": { "ExecuteTime": { @@ -310,16 +311,9 @@ "start_time": "2026-01-28T04:15:12.094221Z" } }, - "source": [ - "dev.cdf_" - ], "outputs": [ { "data": { - "text/plain": [ - " 12-Ult 24-Ult 36-Ult 48-Ult 60-Ult 72-Ult 84-Ult 96-Ult 108-Ult\n", - "(All) 14.446577 4.138701 2.368582 1.625196 1.384499 1.254276 1.154664 1.095637 1.017725" - ], "text/html": [ "\n", " \n", @@ -351,6 +345,10 @@ " \n", " \n", "
" + ], + "text/plain": [ + " 12-Ult 24-Ult 36-Ult 48-Ult 60-Ult 72-Ult 84-Ult 96-Ult 108-Ult\n", + "(All) 14.446577 4.138701 2.368582 1.625196 1.384499 1.254276 1.154664 1.095637 1.017725" ] }, "execution_count": 6, @@ -358,7 +356,9 @@ "output_type": "execute_result" } ], - "execution_count": 6 + "source": [ + "dev.cdf_" + ] }, { "cell_type": "markdown", @@ -370,6 +370,7 @@ }, { "cell_type": "code", + "execution_count": 7, "id": "9cea3555", "metadata": { "ExecuteTime": { @@ -377,16 +378,9 @@ "start_time": "2026-01-28T04:15:12.254174Z" } }, - "source": [ - "dev.ldf_.incr_to_cum()" - ], "outputs": [ { "data": { - "text/plain": [ - " 12-Ult 24-Ult 36-Ult 48-Ult 60-Ult 72-Ult 84-Ult 96-Ult 108-Ult\n", - "(All) 14.446577 4.138701 2.368582 1.625196 1.384499 1.254276 1.154664 1.095637 1.017725" - ], "text/html": [ "\n", " \n", @@ -418,6 +412,10 @@ " \n", " \n", "
" + ], + "text/plain": [ + " 12-Ult 24-Ult 36-Ult 48-Ult 60-Ult 72-Ult 84-Ult 96-Ult 108-Ult\n", + "(All) 14.446577 4.138701 2.368582 1.625196 1.384499 1.254276 1.154664 1.095637 1.017725" ] }, "execution_count": 7, @@ -425,10 +423,13 @@ "output_type": "execute_result" } ], - "execution_count": 7 + "source": [ + "dev.ldf_.incr_to_cum()" + ] }, { "cell_type": "code", + "execution_count": 8, "id": "41a092c0", "metadata": { "ExecuteTime": { @@ -436,16 +437,9 @@ "start_time": "2026-01-28T04:15:12.340110Z" } }, - "source": [ - "dev.cdf_.cum_to_incr()" - ], "outputs": [ { "data": { - "text/plain": [ - " 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120\n", - "(All) 3.490607 1.747333 1.457413 1.173852 1.103824 1.086269 1.053874 1.076555 1.017725" - ], "text/html": [ "\n", " \n", @@ -477,6 +471,10 @@ " \n", " \n", "
" + ], + "text/plain": [ + " 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120\n", + "(All) 3.490607 1.747333 1.457413 1.173852 1.103824 1.086269 1.053874 1.076555 1.017725" ] }, "execution_count": 8, @@ -484,7 +482,9 @@ "output_type": "execute_result" } ], - "execution_count": 8 + "source": [ + "dev.cdf_.cum_to_incr()" + ] }, { "cell_type": "markdown", @@ -496,6 +496,7 @@ }, { "cell_type": "code", + "execution_count": 9, "id": "aec08666", "metadata": { "ExecuteTime": { @@ -503,10 +504,6 @@ "start_time": "2026-01-28T04:15:12.477544Z" } }, - "source": [ - "print(\"Assumption parameter (no underscore):\", dev.average)\n", - "print(\"Estimated parameter (underscore):\\n\", dev.ldf_)" - ], "outputs": [ { "name": "stdout", @@ -519,7 +516,10 @@ ] } ], - "execution_count": 9 + "source": [ + "print(\"Assumption parameter (no underscore):\", dev.average)\n", + "print(\"Estimated parameter (underscore):\\n\", dev.ldf_)" + ] }, { "cell_type": "markdown", @@ -546,6 +546,7 @@ }, { "cell_type": "code", + "execution_count": 10, "id": "3dc6d31a", "metadata": { "ExecuteTime": { @@ -553,26 +554,9 @@ "start_time": "2026-01-28T04:15:12.655950Z" } }, - "source": [ - "genins = cl.load_sample(\"genins\")\n", - "genins" - ], "outputs": [ { "data": { - "text/plain": [ - " 12 24 36 48 60 72 84 96 108 120\n", - "2001 357848.0 1124788.0 1735330.0 2218270.0 2745596.0 3319994.0 3466336.0 3606286.0 3833515.0 3901463.0\n", - "2002 352118.0 1236139.0 2170033.0 3353322.0 3799067.0 4120063.0 4647867.0 4914039.0 5339085.0 NaN\n", - "2003 290507.0 1292306.0 2218525.0 3235179.0 3985995.0 4132918.0 4628910.0 4909315.0 NaN NaN\n", - "2004 310608.0 1418858.0 2195047.0 3757447.0 4029929.0 4381982.0 4588268.0 NaN NaN NaN\n", - "2005 443160.0 1136350.0 2128333.0 2897821.0 3402672.0 3873311.0 NaN NaN NaN NaN\n", - "2006 396132.0 1333217.0 2180715.0 2985752.0 3691712.0 NaN NaN NaN NaN NaN\n", - "2007 440832.0 1288463.0 2419861.0 3483130.0 NaN NaN NaN NaN NaN NaN\n", - "2008 359480.0 1421128.0 2864498.0 NaN NaN NaN NaN NaN NaN NaN\n", - "2009 376686.0 1363294.0 NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2010 344014.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN" - ], "text/html": [ "\n", " \n", @@ -723,6 +707,19 @@ " \n", " \n", "
" + ], + "text/plain": [ + " 12 24 36 48 60 72 84 96 108 120\n", + "2001 357848.0 1124788.0 1735330.0 2218270.0 2745596.0 3319994.0 3466336.0 3606286.0 3833515.0 3901463.0\n", + "2002 352118.0 1236139.0 2170033.0 3353322.0 3799067.0 4120063.0 4647867.0 4914039.0 5339085.0 NaN\n", + "2003 290507.0 1292306.0 2218525.0 3235179.0 3985995.0 4132918.0 4628910.0 4909315.0 NaN NaN\n", + "2004 310608.0 1418858.0 2195047.0 3757447.0 4029929.0 4381982.0 4588268.0 NaN NaN NaN\n", + "2005 443160.0 1136350.0 2128333.0 2897821.0 3402672.0 3873311.0 NaN NaN NaN NaN\n", + "2006 396132.0 1333217.0 2180715.0 2985752.0 3691712.0 NaN NaN NaN NaN NaN\n", + "2007 440832.0 1288463.0 2419861.0 3483130.0 NaN NaN NaN NaN NaN NaN\n", + "2008 359480.0 1421128.0 2864498.0 NaN NaN NaN NaN NaN NaN NaN\n", + "2009 376686.0 1363294.0 NaN NaN NaN NaN NaN NaN NaN NaN\n", + "2010 344014.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN" ] }, "execution_count": 10, @@ -730,7 +727,10 @@ "output_type": "execute_result" } ], - "execution_count": 10 + "source": [ + "genins = cl.load_sample(\"genins\")\n", + "genins" + ] }, { "cell_type": "markdown", @@ -742,6 +742,7 @@ }, { "cell_type": "code", + "execution_count": 11, "id": "98358321", "metadata": { "ExecuteTime": { @@ -749,24 +750,9 @@ "start_time": "2026-01-28T04:15:12.754837Z" } }, - "source": [ - "genins.age_to_age" - ], "outputs": [ { "data": { - "text/plain": [ - " 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120\n", - "2001 3.143200 1.542806 1.278299 1.237719 1.209207 1.044079 1.040374 1.063009 1.017725\n", - "2002 3.510582 1.755493 1.545286 1.132926 1.084493 1.128106 1.057268 1.086496 NaN\n", - "2003 4.448450 1.716718 1.458257 1.232079 1.036860 1.120010 1.060577 NaN NaN\n", - "2004 4.568002 1.547052 1.711784 1.072518 1.087360 1.047076 NaN NaN NaN\n", - "2005 2.564198 1.872956 1.361545 1.174217 1.138315 NaN NaN NaN NaN\n", - "2006 3.365588 1.635679 1.369162 1.236443 NaN NaN NaN NaN NaN\n", - "2007 2.922798 1.878099 1.439393 NaN NaN NaN NaN NaN NaN\n", - "2008 3.953288 2.015651 NaN NaN NaN NaN NaN NaN NaN\n", - "2009 3.619179 NaN NaN NaN NaN NaN NaN NaN NaN" - ], "text/html": [ "\n", " \n", @@ -894,6 +880,18 @@ " \n", " \n", "
" + ], + "text/plain": [ + " 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120\n", + "2001 3.143200 1.542806 1.278299 1.237719 1.209207 1.044079 1.040374 1.063009 1.017725\n", + "2002 3.510582 1.755493 1.545286 1.132926 1.084493 1.128106 1.057268 1.086496 NaN\n", + "2003 4.448450 1.716718 1.458257 1.232079 1.036860 1.120010 1.060577 NaN NaN\n", + "2004 4.568002 1.547052 1.711784 1.072518 1.087360 1.047076 NaN NaN NaN\n", + "2005 2.564198 1.872956 1.361545 1.174217 1.138315 NaN NaN NaN NaN\n", + "2006 3.365588 1.635679 1.369162 1.236443 NaN NaN NaN NaN NaN\n", + "2007 2.922798 1.878099 1.439393 NaN NaN NaN NaN NaN NaN\n", + "2008 3.953288 2.015651 NaN NaN NaN NaN NaN NaN NaN\n", + "2009 3.619179 NaN NaN NaN NaN NaN NaN NaN NaN" ] }, "execution_count": 11, @@ -901,7 +899,9 @@ "output_type": "execute_result" } ], - "execution_count": 11 + "source": [ + "genins.age_to_age" + ] }, { "cell_type": "markdown", @@ -913,6 +913,7 @@ }, { "cell_type": "code", + "execution_count": 12, "id": "dfa6cf6b", "metadata": { "ExecuteTime": { @@ -920,15 +921,9 @@ "start_time": "2026-01-28T04:15:12.855433Z" } }, - "source": [ - "genins.age_to_age.heatmap()" - ], "outputs": [ { "data": { - "text/plain": [ - "" - ], "text/html": [ "