Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light IH support focusing on Conversion monitoring #299

Merged
merged 11 commits into from
Dec 20, 2024
158 changes: 158 additions & 0 deletions examples/ih/Conversion_Reporting.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pdstools import IH\n",
"\n",
"import plotly.io as pio\n",
"import plotly as plotly\n",
"\n",
"plotly.offline.init_notebook_mode()\n",
"pio.renderers.default = \"vscode\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Conversion Results\n",
"\n",
"Visualization of conversion modeling results from IH data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import polars as pl\n",
"\n",
"ih_export_file = Path(\n",
" \"./Data-pxStrategyResult_InteractionFiles_20241213T091932_GMT.zip\"\n",
")\n",
"\n",
"if not ih_export_file.exists():\n",
" ih = IH.from_mock_data()\n",
"else:\n",
" ih = IH.from_ds_export(\n",
" ih_export_file,\n",
" query=pl.col.ExperimentGroup.is_not_null() & (pl.col.ExperimentGroup != \"\"),\n",
" )\n",
"\n",
"ih.aggregates.summary_success_rates(by=[\"ExperimentGroup\", \"Channel\"]).drop(\n",
" \"Outcomes\"\n",
").collect().to_pandas().style.hide()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ih.plots.conversion_overall_gauges(\n",
" experiment_field=\"ExperimentGroup\",\n",
" by=\"Channel\",\n",
" reference_values={\"Web\": 0.055, \"Email\": 0.09},\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Detailed View \n",
"\n",
"Showing conversion rates for all actions."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ih.plots.conversion_success_rates_tree_map()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Conversion Rate Trends\n",
"\n",
"side-by-side bars and lines (separate methods) with error bars"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ih.plots.conversion_success_rates_trend_bar(\n",
" experiment_field=\"ExperimentGroup\",\n",
" every=\"1w\",\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Engagement"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ih.plots.egagement_overall_gauges(\n",
" experiment_field=\"ExperimentGroup\",\n",
" by=\"Channel\",\n",
" reference_values={\"Web\": 0.20, \"Email\": 0.20},\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ih.plots.conversion_success_rates_trend_line(\n",
" by=\"Channel\"\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
58 changes: 34 additions & 24 deletions examples/ih/Example_IH_Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
operdeck marked this conversation as resolved.
Show resolved Hide resolved
"ename": "ModuleNotFoundError",
"evalue": "No module named 'cdhtools'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[1], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpd\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01msys\u001b[39;00m\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mcdhtools\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mIHanalysis\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mcdhtools\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcdh_utils\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m readDSExport\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmatplotlib\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpyplot\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mplt\u001b[39;00m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'cdhtools'"
]
}
],
"source": [
"import pandas as pd\n",
"import sys\n",
Expand All @@ -18,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -35,7 +47,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -51,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -274,7 +286,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -548,7 +560,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -578,7 +590,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -607,7 +619,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -638,7 +650,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -668,7 +680,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -699,7 +711,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -728,7 +740,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -780,7 +792,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -809,7 +821,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -826,7 +838,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -856,7 +868,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -886,7 +898,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -895,7 +907,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -932,7 +944,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -968,11 +980,9 @@
}
],
"metadata": {
"interpreter": {
"hash": "0c5c31b7614ab5f7bbff6555bdc6f3ec4cea8754d51936ee45052251e94c1071"
},
"kernelspec": {
"display_name": "Python 3.9.4 64-bit ('newvfenv': conda)",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
Expand All @@ -985,7 +995,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 2 additions & 0 deletions python/pdstools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from polars import enable_string_cache

from .adm.ADMDatamart import ADMDatamart
from .ih.IH import IH
from .infinity import Infinity
from .pega_io import Anonymization, read_ds_export
from .prediction.Prediction import Prediction
Expand All @@ -23,6 +24,7 @@

__all__ = [
"ADMDatamart",
"IH",
"Anonymization",
"read_ds_export",
"Prediction",
Expand Down
Loading
Loading