diff --git a/examples/adm/ADMBinningInsights.ipynb b/examples/adm/ADMBinningInsights.ipynb
index 891d54ae..93abdc01 100644
--- a/examples/adm/ADMBinningInsights.ipynb
+++ b/examples/adm/ADMBinningInsights.ipynb
@@ -14,8 +14,10 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
+ "execution_count": 1,
+ "metadata": {
+ "nbsphinx": "hidden"
+ },
"outputs": [],
"source": [
"# These lines are only for rendering in the docs, and are hidden through Jupyter tags\n",
@@ -34,27 +36,67 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Temporarily add the BinAggregator path explicitly. This is only temp while\n",
- "# not part of a released version of PDS tools.\n",
- "\n",
- "import site\n",
- "import os\n",
- "import pathlib\n",
- "\n",
- "notebook_folder = os.getcwd()\n",
- "basePath = pathlib.Path(notebook_folder).parent.parent\n",
- "site.addsitedir(pathlib.Path(basePath, 'python/pdstools/adm'))\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ " \n",
+ " "
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "
"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"from pdstools import ADMDatamart, datasets\n",
"import polars as pl\n",
@@ -95,9 +137,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"fig = dm.plotPredictorBinning(modelids=['08ca1302-9fc0-57bf-9031-d4179d400493'], predictors=['Customer.AnnualIncome'])\n",
"fig.update_layout(height=400, width=800, xaxis_title=\"\")\n",
@@ -141,11 +217,45 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
- "from BinAggregator import BinAggregator\n",
+ "from pdstools import BinAggregator\n",
"\n",
"# For PDS tools example keep dm as above but the subset argument is important\n",
"dm = datasets.CDHSample(subset=False)\n",
@@ -177,18 +287,88 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (4, 9)PredictorName | BinIndex | BinLowerBound | BinUpperBound | BinSymbol | Lift | BinResponses | BinCoverage | Models |
---|
str | i64 | f64 | f64 | str | f64 | f64 | f64 | i32 |
"Customer.Age" | 1 | 20.0 | 35.0 | "<35.0" | 0.066667 | 433.333333 | 1.0 | 1 |
"Customer.Age" | 2 | 35.0 | 50.0 | "<50.0" | -0.1 | 600.0 | 1.0 | 1 |
"Customer.Age" | 3 | 50.0 | 65.0 | "<65.0" | 2.0 | 240.0 | 1.0 | 1 |
"Customer.Age" | 4 | 65.0 | 80.0 | "<80.0" | 2.0 | 160.0 | 0.666667 | 1 |
"
+ ],
+ "text/plain": [
+ "shape: (4, 9)\n",
+ "┌────────────┬──────────┬────────────┬────────────┬───┬──────────┬────────────┬───────────┬────────┐\n",
+ "│ PredictorN ┆ BinIndex ┆ BinLowerBo ┆ BinUpperBo ┆ … ┆ Lift ┆ BinRespons ┆ BinCovera ┆ Models │\n",
+ "│ ame ┆ --- ┆ und ┆ und ┆ ┆ --- ┆ es ┆ ge ┆ --- │\n",
+ "│ --- ┆ i64 ┆ --- ┆ --- ┆ ┆ f64 ┆ --- ┆ --- ┆ i32 │\n",
+ "│ str ┆ ┆ f64 ┆ f64 ┆ ┆ ┆ f64 ┆ f64 ┆ │\n",
+ "╞════════════╪══════════╪════════════╪════════════╪═══╪══════════╪════════════╪═══════════╪════════╡\n",
+ "│ Customer.A ┆ 1 ┆ 20.0 ┆ 35.0 ┆ … ┆ 0.066667 ┆ 433.333333 ┆ 1.0 ┆ 1 │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 2 ┆ 35.0 ┆ 50.0 ┆ … ┆ -0.1 ┆ 600.0 ┆ 1.0 ┆ 1 │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 3 ┆ 50.0 ┆ 65.0 ┆ … ┆ 2.0 ┆ 240.0 ┆ 1.0 ┆ 1 │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 4 ┆ 65.0 ┆ 80.0 ┆ … ┆ 2.0 ┆ 160.0 ┆ 0.666667 ┆ 1 │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n",
+ "└────────────┴──────────┴────────────┴────────────┴───┴──────────┴────────────┴───────────┴────────┘"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"myAggregator.combine_two_numbinnings(source, target)"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"fig = myAggregator.roll_up(\"Customer.Age\")\n",
"fig.update_layout(height=300, width=600)\n",
@@ -206,9 +386,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"fig = myAggregator.roll_up(\"Customer.Age\", minimum=20, maximum=80, n=5, aggregation=\"Group\")\n",
"fig.update_layout(height=500)\n",
@@ -224,9 +438,54 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
shape: (20, 10)PredictorName | BinIndex | BinLowerBound | BinUpperBound | BinSymbol | Lift | BinResponses | BinCoverage | Models | Group |
---|
str | i64 | f64 | f64 | str | f64 | f64 | f64 | i32 | str |
"Customer.Age" | 1 | 20.0 | 32.0 | "<32.0" | 0.229643 | 4398.940698 | 10.0 | 10 | "AutoLoans" |
"Customer.Age" | 2 | 32.0 | 44.0 | "<44.0" | -0.261505 | 8280.450496 | 10.0 | 10 | "AutoLoans" |
"Customer.Age" | 3 | 44.0 | 56.0 | "<56.0" | 0.281045 | 4540.748856 | 10.0 | 10 | "AutoLoans" |
"Customer.Age" | 4 | 56.0 | 68.0 | "<68.0" | 0.501178 | 1272.362768 | 10.0 | 10 | "AutoLoans" |
"Customer.Age" | 5 | 68.0 | 80.0 | "<80.0" | 0.510309 | 965.237926 | 8.166667 | 10 | "AutoLoans" |
"Customer.Age" | 1 | 20.0 | 32.0 | "<32.0" | 0.11059 | 995.724951 | 7.0 | 7 | "HomeLoans" |
"Customer.Age" | 2 | 32.0 | 44.0 | "<44.0" | -0.078623 | 1975.071325 | 7.0 | 7 | "HomeLoans" |
"Customer.Age" | 3 | 44.0 | 56.0 | "<56.0" | 0.047313 | 1350.110244 | 7.0 | 7 | "HomeLoans" |
"Customer.Age" | 4 | 56.0 | 68.0 | "<68.0" | 0.145987 | 251.370112 | 7.0 | 7 | "HomeLoans" |
"Customer.Age" | 5 | 68.0 | 80.0 | "<80.0" | 0.167526 | 209.475093 | 5.083333 | 7 | "HomeLoans" |
"Customer.Age" | 1 | 20.0 | 32.0 | "<32.0" | 0.038873 | 247.676726 | 1.0 | 1 | "CreditCards" |
"Customer.Age" | 2 | 32.0 | 44.0 | "<44.0" | -0.598058 | 324.579816 | 1.0 | 1 | "CreditCards" |
"Customer.Age" | 3 | 44.0 | 56.0 | "<56.0" | 0.996987 | 82.989379 | 1.0 | 1 | "CreditCards" |
"Customer.Age" | 4 | 56.0 | 68.0 | "<68.0" | 1.007692 | 81.367929 | 1.0 | 1 | "CreditCards" |
"Customer.Age" | 5 | 68.0 | 80.0 | "<80.0" | 1.007692 | 67.806607 | 0.833333 | 1 | "CreditCards" |
"Customer.Age" | 1 | 20.0 | 32.0 | "<32.0" | 0.155355 | 1749.921628 | 2.0 | 2 | "Bundles" |
"Customer.Age" | 2 | 32.0 | 44.0 | "<44.0" | -0.124786 | 3979.820578 | 2.0 | 2 | "Bundles" |
"Customer.Age" | 3 | 44.0 | 56.0 | "<56.0" | 0.244397 | 2843.339271 | 2.0 | 2 | "Bundles" |
"Customer.Age" | 4 | 56.0 | 68.0 | "<68.0" | -0.139278 | 502.650345 | 2.0 | 2 | "Bundles" |
"Customer.Age" | 5 | 68.0 | 80.0 | "<80.0" | -0.209373 | 331.583984 | 1.666667 | 2 | "Bundles" |
"
+ ],
+ "text/plain": [
+ "shape: (20, 10)\n",
+ "┌────────────┬──────────┬────────────┬────────────┬───┬───────────┬───────────┬────────┬───────────┐\n",
+ "│ PredictorN ┆ BinIndex ┆ BinLowerBo ┆ BinUpperBo ┆ … ┆ BinRespon ┆ BinCovera ┆ Models ┆ Group │\n",
+ "│ ame ┆ --- ┆ und ┆ und ┆ ┆ ses ┆ ge ┆ --- ┆ --- │\n",
+ "│ --- ┆ i64 ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ i32 ┆ str │\n",
+ "│ str ┆ ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ ┆ │\n",
+ "╞════════════╪══════════╪════════════╪════════════╪═══╪═══════════╪═══════════╪════════╪═══════════╡\n",
+ "│ Customer.A ┆ 1 ┆ 20.0 ┆ 32.0 ┆ … ┆ 4398.9406 ┆ 10.0 ┆ 10 ┆ AutoLoans │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ 98 ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 2 ┆ 32.0 ┆ 44.0 ┆ … ┆ 8280.4504 ┆ 10.0 ┆ 10 ┆ AutoLoans │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ 96 ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 3 ┆ 44.0 ┆ 56.0 ┆ … ┆ 4540.7488 ┆ 10.0 ┆ 10 ┆ AutoLoans │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ 56 ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 4 ┆ 56.0 ┆ 68.0 ┆ … ┆ 1272.3627 ┆ 10.0 ┆ 10 ┆ AutoLoans │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ 68 ┆ ┆ ┆ │\n",
+ "│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n",
+ "│ Customer.A ┆ 2 ┆ 32.0 ┆ 44.0 ┆ … ┆ 3979.8205 ┆ 2.0 ┆ 2 ┆ Bundles │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ 78 ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 3 ┆ 44.0 ┆ 56.0 ┆ … ┆ 2843.3392 ┆ 2.0 ┆ 2 ┆ Bundles │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ 71 ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 4 ┆ 56.0 ┆ 68.0 ┆ … ┆ 502.65034 ┆ 2.0 ┆ 2 ┆ Bundles │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ 5 ┆ ┆ ┆ │\n",
+ "│ Customer.A ┆ 5 ┆ 68.0 ┆ 80.0 ┆ … ┆ 331.58398 ┆ 1.666667 ┆ 2 ┆ Bundles │\n",
+ "│ ge ┆ ┆ ┆ ┆ ┆ 4 ┆ ┆ ┆ │\n",
+ "└────────────┴──────────┴────────────┴────────────┴───┴───────────┴───────────┴────────┴───────────┘"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"myAggregator.roll_up(\"Customer.Age\", minimum=20, maximum=80, n=5, aggregation=\"Group\", return_df=True)"
]
@@ -240,9 +499,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"fig = myAggregator.roll_up(\"Customer.AnnualIncome\", boundaries=[10000, 20000, 30000], n=8, distribution=\"log\", aggregation=\"Channel\")\n",
"fig.update_layout(height=300)\n",
@@ -267,9 +560,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"fig = myAggregator.roll_up(\"Customer.MaritalStatus\")\n",
"fig.update_layout(height=300, width=600)\n",
@@ -289,9 +616,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"top_predictors = dm.plotPredictorPerformance(\n",
" top_n = 10, \n",
@@ -321,9 +682,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"binAggregator = BinAggregator(dm, query=pl.col(\"Group\").cast(pl.Utf8).str.contains(\"Loan\"))\n",
"fig = binAggregator.roll_up([\"Customer.Prefix\", \"Customer.Age\"], n=6, aggregation=\"Group\")\n",
diff --git a/python/docs/Makefile b/python/docs/Makefile
index 19329da1..cc480644 100644
--- a/python/docs/Makefile
+++ b/python/docs/Makefile
@@ -23,7 +23,7 @@ help:
%: Makefile
mkdir -p source/articles
- cp ../../examples/datamart/Example_ADM_Analysis.ipynb ../../examples/valuefinder/* ../../examples/adm/AGBModelVisualisation.ipynb ../../examples/hds/Example_Data_Anonymization.ipynb ../../examples/articles/*.ipynb source/articles
+ cp ../../examples/datamart/Example_ADM_Analysis.ipynb ../../examples/valuefinder/* ../../examples/adm/AGBModelVisualisation.ipynb ../../examples/adm/ADMBinningInsights.ipynb ../../examples/hds/Example_Data_Anonymization.ipynb ../../examples/articles/*.ipynb source/articles
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
rm -rf source/articles/output
rm source/articles/*
diff --git a/python/docs/source/index.rst b/python/docs/source/index.rst
index 58350e61..a5307eb9 100644
--- a/python/docs/source/index.rst
+++ b/python/docs/source/index.rst
@@ -19,6 +19,7 @@ Welcome to the PDS Tools Python documentation
:caption: Examples
articles/Example_ADM_Analysis
+ articles/ADMBinningInsights
articles/AGBModelVisualisation
articles/vf_analysis
articles/Example_Data_Anonymization