churnkit 0.75.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/00_start_here.ipynb +647 -0
  2. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01_data_discovery.ipynb +1165 -0
  3. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01a_a_temporal_text_deep_dive.ipynb +961 -0
  4. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01a_temporal_deep_dive.ipynb +1690 -0
  5. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01b_temporal_quality.ipynb +679 -0
  6. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01c_temporal_patterns.ipynb +3305 -0
  7. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01d_event_aggregation.ipynb +1463 -0
  8. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/02_column_deep_dive.ipynb +1430 -0
  9. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/02a_text_columns_deep_dive.ipynb +854 -0
  10. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/03_quality_assessment.ipynb +1639 -0
  11. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/04_relationship_analysis.ipynb +1890 -0
  12. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/05_multi_dataset.ipynb +1457 -0
  13. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/06_feature_opportunities.ipynb +1624 -0
  14. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/07_modeling_readiness.ipynb +780 -0
  15. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/08_baseline_experiments.ipynb +979 -0
  16. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/09_business_alignment.ipynb +572 -0
  17. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/10_spec_generation.ipynb +1179 -0
  18. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/11_scoring_validation.ipynb +1418 -0
  19. churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/12_view_documentation.ipynb +151 -0
  20. churnkit-0.75.0a1.dist-info/METADATA +229 -0
  21. churnkit-0.75.0a1.dist-info/RECORD +302 -0
  22. churnkit-0.75.0a1.dist-info/WHEEL +4 -0
  23. churnkit-0.75.0a1.dist-info/entry_points.txt +2 -0
  24. churnkit-0.75.0a1.dist-info/licenses/LICENSE +202 -0
  25. customer_retention/__init__.py +37 -0
  26. customer_retention/analysis/__init__.py +0 -0
  27. customer_retention/analysis/auto_explorer/__init__.py +62 -0
  28. customer_retention/analysis/auto_explorer/exploration_manager.py +470 -0
  29. customer_retention/analysis/auto_explorer/explorer.py +258 -0
  30. customer_retention/analysis/auto_explorer/findings.py +291 -0
  31. customer_retention/analysis/auto_explorer/layered_recommendations.py +485 -0
  32. customer_retention/analysis/auto_explorer/recommendation_builder.py +148 -0
  33. customer_retention/analysis/auto_explorer/recommendations.py +418 -0
  34. customer_retention/analysis/business/__init__.py +26 -0
  35. customer_retention/analysis/business/ab_test_designer.py +144 -0
  36. customer_retention/analysis/business/fairness_analyzer.py +166 -0
  37. customer_retention/analysis/business/intervention_matcher.py +121 -0
  38. customer_retention/analysis/business/report_generator.py +222 -0
  39. customer_retention/analysis/business/risk_profile.py +199 -0
  40. customer_retention/analysis/business/roi_analyzer.py +139 -0
  41. customer_retention/analysis/diagnostics/__init__.py +20 -0
  42. customer_retention/analysis/diagnostics/calibration_analyzer.py +133 -0
  43. customer_retention/analysis/diagnostics/cv_analyzer.py +144 -0
  44. customer_retention/analysis/diagnostics/error_analyzer.py +107 -0
  45. customer_retention/analysis/diagnostics/leakage_detector.py +394 -0
  46. customer_retention/analysis/diagnostics/noise_tester.py +140 -0
  47. customer_retention/analysis/diagnostics/overfitting_analyzer.py +190 -0
  48. customer_retention/analysis/diagnostics/segment_analyzer.py +122 -0
  49. customer_retention/analysis/discovery/__init__.py +8 -0
  50. customer_retention/analysis/discovery/config_generator.py +49 -0
  51. customer_retention/analysis/discovery/discovery_flow.py +19 -0
  52. customer_retention/analysis/discovery/type_inferencer.py +147 -0
  53. customer_retention/analysis/interpretability/__init__.py +13 -0
  54. customer_retention/analysis/interpretability/cohort_analyzer.py +185 -0
  55. customer_retention/analysis/interpretability/counterfactual.py +175 -0
  56. customer_retention/analysis/interpretability/individual_explainer.py +141 -0
  57. customer_retention/analysis/interpretability/pdp_generator.py +103 -0
  58. customer_retention/analysis/interpretability/shap_explainer.py +106 -0
  59. customer_retention/analysis/jupyter_save_hook.py +28 -0
  60. customer_retention/analysis/notebook_html_exporter.py +136 -0
  61. customer_retention/analysis/notebook_progress.py +60 -0
  62. customer_retention/analysis/plotly_preprocessor.py +154 -0
  63. customer_retention/analysis/recommendations/__init__.py +54 -0
  64. customer_retention/analysis/recommendations/base.py +158 -0
  65. customer_retention/analysis/recommendations/cleaning/__init__.py +11 -0
  66. customer_retention/analysis/recommendations/cleaning/consistency.py +107 -0
  67. customer_retention/analysis/recommendations/cleaning/deduplicate.py +94 -0
  68. customer_retention/analysis/recommendations/cleaning/impute.py +67 -0
  69. customer_retention/analysis/recommendations/cleaning/outlier.py +71 -0
  70. customer_retention/analysis/recommendations/datetime/__init__.py +3 -0
  71. customer_retention/analysis/recommendations/datetime/extract.py +149 -0
  72. customer_retention/analysis/recommendations/encoding/__init__.py +3 -0
  73. customer_retention/analysis/recommendations/encoding/categorical.py +114 -0
  74. customer_retention/analysis/recommendations/pipeline.py +74 -0
  75. customer_retention/analysis/recommendations/registry.py +76 -0
  76. customer_retention/analysis/recommendations/selection/__init__.py +3 -0
  77. customer_retention/analysis/recommendations/selection/drop_column.py +56 -0
  78. customer_retention/analysis/recommendations/transform/__init__.py +4 -0
  79. customer_retention/analysis/recommendations/transform/power.py +94 -0
  80. customer_retention/analysis/recommendations/transform/scale.py +112 -0
  81. customer_retention/analysis/visualization/__init__.py +15 -0
  82. customer_retention/analysis/visualization/chart_builder.py +2619 -0
  83. customer_retention/analysis/visualization/console.py +122 -0
  84. customer_retention/analysis/visualization/display.py +171 -0
  85. customer_retention/analysis/visualization/number_formatter.py +36 -0
  86. customer_retention/artifacts/__init__.py +3 -0
  87. customer_retention/artifacts/fit_artifact_registry.py +146 -0
  88. customer_retention/cli.py +93 -0
  89. customer_retention/core/__init__.py +0 -0
  90. customer_retention/core/compat/__init__.py +193 -0
  91. customer_retention/core/compat/detection.py +99 -0
  92. customer_retention/core/compat/ops.py +48 -0
  93. customer_retention/core/compat/pandas_backend.py +57 -0
  94. customer_retention/core/compat/spark_backend.py +75 -0
  95. customer_retention/core/components/__init__.py +11 -0
  96. customer_retention/core/components/base.py +79 -0
  97. customer_retention/core/components/components/__init__.py +13 -0
  98. customer_retention/core/components/components/deployer.py +26 -0
  99. customer_retention/core/components/components/explainer.py +26 -0
  100. customer_retention/core/components/components/feature_eng.py +33 -0
  101. customer_retention/core/components/components/ingester.py +34 -0
  102. customer_retention/core/components/components/profiler.py +34 -0
  103. customer_retention/core/components/components/trainer.py +38 -0
  104. customer_retention/core/components/components/transformer.py +36 -0
  105. customer_retention/core/components/components/validator.py +37 -0
  106. customer_retention/core/components/enums.py +33 -0
  107. customer_retention/core/components/orchestrator.py +94 -0
  108. customer_retention/core/components/registry.py +59 -0
  109. customer_retention/core/config/__init__.py +39 -0
  110. customer_retention/core/config/column_config.py +95 -0
  111. customer_retention/core/config/experiments.py +71 -0
  112. customer_retention/core/config/pipeline_config.py +117 -0
  113. customer_retention/core/config/source_config.py +83 -0
  114. customer_retention/core/utils/__init__.py +28 -0
  115. customer_retention/core/utils/leakage.py +85 -0
  116. customer_retention/core/utils/severity.py +53 -0
  117. customer_retention/core/utils/statistics.py +90 -0
  118. customer_retention/generators/__init__.py +0 -0
  119. customer_retention/generators/notebook_generator/__init__.py +167 -0
  120. customer_retention/generators/notebook_generator/base.py +55 -0
  121. customer_retention/generators/notebook_generator/cell_builder.py +49 -0
  122. customer_retention/generators/notebook_generator/config.py +47 -0
  123. customer_retention/generators/notebook_generator/databricks_generator.py +48 -0
  124. customer_retention/generators/notebook_generator/local_generator.py +48 -0
  125. customer_retention/generators/notebook_generator/project_init.py +174 -0
  126. customer_retention/generators/notebook_generator/runner.py +150 -0
  127. customer_retention/generators/notebook_generator/script_generator.py +110 -0
  128. customer_retention/generators/notebook_generator/stages/__init__.py +19 -0
  129. customer_retention/generators/notebook_generator/stages/base_stage.py +86 -0
  130. customer_retention/generators/notebook_generator/stages/s01_ingestion.py +100 -0
  131. customer_retention/generators/notebook_generator/stages/s02_profiling.py +95 -0
  132. customer_retention/generators/notebook_generator/stages/s03_cleaning.py +180 -0
  133. customer_retention/generators/notebook_generator/stages/s04_transformation.py +165 -0
  134. customer_retention/generators/notebook_generator/stages/s05_feature_engineering.py +115 -0
  135. customer_retention/generators/notebook_generator/stages/s06_feature_selection.py +97 -0
  136. customer_retention/generators/notebook_generator/stages/s07_model_training.py +176 -0
  137. customer_retention/generators/notebook_generator/stages/s08_deployment.py +81 -0
  138. customer_retention/generators/notebook_generator/stages/s09_monitoring.py +112 -0
  139. customer_retention/generators/notebook_generator/stages/s10_batch_inference.py +642 -0
  140. customer_retention/generators/notebook_generator/stages/s11_feature_store.py +348 -0
  141. customer_retention/generators/orchestration/__init__.py +23 -0
  142. customer_retention/generators/orchestration/code_generator.py +196 -0
  143. customer_retention/generators/orchestration/context.py +147 -0
  144. customer_retention/generators/orchestration/data_materializer.py +188 -0
  145. customer_retention/generators/orchestration/databricks_exporter.py +411 -0
  146. customer_retention/generators/orchestration/doc_generator.py +311 -0
  147. customer_retention/generators/pipeline_generator/__init__.py +26 -0
  148. customer_retention/generators/pipeline_generator/findings_parser.py +727 -0
  149. customer_retention/generators/pipeline_generator/generator.py +142 -0
  150. customer_retention/generators/pipeline_generator/models.py +166 -0
  151. customer_retention/generators/pipeline_generator/renderer.py +2125 -0
  152. customer_retention/generators/spec_generator/__init__.py +37 -0
  153. customer_retention/generators/spec_generator/databricks_generator.py +433 -0
  154. customer_retention/generators/spec_generator/generic_generator.py +373 -0
  155. customer_retention/generators/spec_generator/mlflow_pipeline_generator.py +685 -0
  156. customer_retention/generators/spec_generator/pipeline_spec.py +298 -0
  157. customer_retention/integrations/__init__.py +0 -0
  158. customer_retention/integrations/adapters/__init__.py +13 -0
  159. customer_retention/integrations/adapters/base.py +10 -0
  160. customer_retention/integrations/adapters/factory.py +25 -0
  161. customer_retention/integrations/adapters/feature_store/__init__.py +6 -0
  162. customer_retention/integrations/adapters/feature_store/base.py +57 -0
  163. customer_retention/integrations/adapters/feature_store/databricks.py +94 -0
  164. customer_retention/integrations/adapters/feature_store/feast_adapter.py +97 -0
  165. customer_retention/integrations/adapters/feature_store/local.py +75 -0
  166. customer_retention/integrations/adapters/mlflow/__init__.py +6 -0
  167. customer_retention/integrations/adapters/mlflow/base.py +32 -0
  168. customer_retention/integrations/adapters/mlflow/databricks.py +54 -0
  169. customer_retention/integrations/adapters/mlflow/experiment_tracker.py +161 -0
  170. customer_retention/integrations/adapters/mlflow/local.py +50 -0
  171. customer_retention/integrations/adapters/storage/__init__.py +5 -0
  172. customer_retention/integrations/adapters/storage/base.py +33 -0
  173. customer_retention/integrations/adapters/storage/databricks.py +76 -0
  174. customer_retention/integrations/adapters/storage/local.py +59 -0
  175. customer_retention/integrations/feature_store/__init__.py +47 -0
  176. customer_retention/integrations/feature_store/definitions.py +215 -0
  177. customer_retention/integrations/feature_store/manager.py +744 -0
  178. customer_retention/integrations/feature_store/registry.py +412 -0
  179. customer_retention/integrations/iteration/__init__.py +28 -0
  180. customer_retention/integrations/iteration/context.py +212 -0
  181. customer_retention/integrations/iteration/feedback_collector.py +184 -0
  182. customer_retention/integrations/iteration/orchestrator.py +168 -0
  183. customer_retention/integrations/iteration/recommendation_tracker.py +341 -0
  184. customer_retention/integrations/iteration/signals.py +212 -0
  185. customer_retention/integrations/llm_context/__init__.py +4 -0
  186. customer_retention/integrations/llm_context/context_builder.py +201 -0
  187. customer_retention/integrations/llm_context/prompts.py +100 -0
  188. customer_retention/integrations/streaming/__init__.py +103 -0
  189. customer_retention/integrations/streaming/batch_integration.py +149 -0
  190. customer_retention/integrations/streaming/early_warning_model.py +227 -0
  191. customer_retention/integrations/streaming/event_schema.py +214 -0
  192. customer_retention/integrations/streaming/online_store_writer.py +249 -0
  193. customer_retention/integrations/streaming/realtime_scorer.py +261 -0
  194. customer_retention/integrations/streaming/trigger_engine.py +293 -0
  195. customer_retention/integrations/streaming/window_aggregator.py +393 -0
  196. customer_retention/stages/__init__.py +0 -0
  197. customer_retention/stages/cleaning/__init__.py +9 -0
  198. customer_retention/stages/cleaning/base.py +28 -0
  199. customer_retention/stages/cleaning/missing_handler.py +160 -0
  200. customer_retention/stages/cleaning/outlier_handler.py +204 -0
  201. customer_retention/stages/deployment/__init__.py +28 -0
  202. customer_retention/stages/deployment/batch_scorer.py +106 -0
  203. customer_retention/stages/deployment/champion_challenger.py +299 -0
  204. customer_retention/stages/deployment/model_registry.py +182 -0
  205. customer_retention/stages/deployment/retraining_trigger.py +245 -0
  206. customer_retention/stages/features/__init__.py +73 -0
  207. customer_retention/stages/features/behavioral_features.py +266 -0
  208. customer_retention/stages/features/customer_segmentation.py +505 -0
  209. customer_retention/stages/features/feature_definitions.py +265 -0
  210. customer_retention/stages/features/feature_engineer.py +551 -0
  211. customer_retention/stages/features/feature_manifest.py +340 -0
  212. customer_retention/stages/features/feature_selector.py +239 -0
  213. customer_retention/stages/features/interaction_features.py +160 -0
  214. customer_retention/stages/features/temporal_features.py +243 -0
  215. customer_retention/stages/ingestion/__init__.py +9 -0
  216. customer_retention/stages/ingestion/load_result.py +32 -0
  217. customer_retention/stages/ingestion/loaders.py +195 -0
  218. customer_retention/stages/ingestion/source_registry.py +130 -0
  219. customer_retention/stages/modeling/__init__.py +31 -0
  220. customer_retention/stages/modeling/baseline_trainer.py +139 -0
  221. customer_retention/stages/modeling/cross_validator.py +125 -0
  222. customer_retention/stages/modeling/data_splitter.py +205 -0
  223. customer_retention/stages/modeling/feature_scaler.py +99 -0
  224. customer_retention/stages/modeling/hyperparameter_tuner.py +107 -0
  225. customer_retention/stages/modeling/imbalance_handler.py +282 -0
  226. customer_retention/stages/modeling/mlflow_logger.py +95 -0
  227. customer_retention/stages/modeling/model_comparator.py +149 -0
  228. customer_retention/stages/modeling/model_evaluator.py +138 -0
  229. customer_retention/stages/modeling/threshold_optimizer.py +131 -0
  230. customer_retention/stages/monitoring/__init__.py +37 -0
  231. customer_retention/stages/monitoring/alert_manager.py +328 -0
  232. customer_retention/stages/monitoring/drift_detector.py +201 -0
  233. customer_retention/stages/monitoring/performance_monitor.py +242 -0
  234. customer_retention/stages/preprocessing/__init__.py +5 -0
  235. customer_retention/stages/preprocessing/transformer_manager.py +284 -0
  236. customer_retention/stages/profiling/__init__.py +256 -0
  237. customer_retention/stages/profiling/categorical_distribution.py +269 -0
  238. customer_retention/stages/profiling/categorical_target_analyzer.py +274 -0
  239. customer_retention/stages/profiling/column_profiler.py +527 -0
  240. customer_retention/stages/profiling/distribution_analysis.py +483 -0
  241. customer_retention/stages/profiling/drift_detector.py +310 -0
  242. customer_retention/stages/profiling/feature_capacity.py +507 -0
  243. customer_retention/stages/profiling/pattern_analysis_config.py +513 -0
  244. customer_retention/stages/profiling/profile_result.py +212 -0
  245. customer_retention/stages/profiling/quality_checks.py +1632 -0
  246. customer_retention/stages/profiling/relationship_detector.py +256 -0
  247. customer_retention/stages/profiling/relationship_recommender.py +454 -0
  248. customer_retention/stages/profiling/report_generator.py +520 -0
  249. customer_retention/stages/profiling/scd_analyzer.py +151 -0
  250. customer_retention/stages/profiling/segment_analyzer.py +632 -0
  251. customer_retention/stages/profiling/segment_aware_outlier.py +265 -0
  252. customer_retention/stages/profiling/target_level_analyzer.py +217 -0
  253. customer_retention/stages/profiling/temporal_analyzer.py +388 -0
  254. customer_retention/stages/profiling/temporal_coverage.py +488 -0
  255. customer_retention/stages/profiling/temporal_feature_analyzer.py +692 -0
  256. customer_retention/stages/profiling/temporal_feature_engineer.py +703 -0
  257. customer_retention/stages/profiling/temporal_pattern_analyzer.py +636 -0
  258. customer_retention/stages/profiling/temporal_quality_checks.py +278 -0
  259. customer_retention/stages/profiling/temporal_target_analyzer.py +241 -0
  260. customer_retention/stages/profiling/text_embedder.py +87 -0
  261. customer_retention/stages/profiling/text_processor.py +115 -0
  262. customer_retention/stages/profiling/text_reducer.py +60 -0
  263. customer_retention/stages/profiling/time_series_profiler.py +303 -0
  264. customer_retention/stages/profiling/time_window_aggregator.py +376 -0
  265. customer_retention/stages/profiling/type_detector.py +382 -0
  266. customer_retention/stages/profiling/window_recommendation.py +288 -0
  267. customer_retention/stages/temporal/__init__.py +166 -0
  268. customer_retention/stages/temporal/access_guard.py +180 -0
  269. customer_retention/stages/temporal/cutoff_analyzer.py +235 -0
  270. customer_retention/stages/temporal/data_preparer.py +178 -0
  271. customer_retention/stages/temporal/point_in_time_join.py +134 -0
  272. customer_retention/stages/temporal/point_in_time_registry.py +148 -0
  273. customer_retention/stages/temporal/scenario_detector.py +163 -0
  274. customer_retention/stages/temporal/snapshot_manager.py +259 -0
  275. customer_retention/stages/temporal/synthetic_coordinator.py +66 -0
  276. customer_retention/stages/temporal/timestamp_discovery.py +531 -0
  277. customer_retention/stages/temporal/timestamp_manager.py +255 -0
  278. customer_retention/stages/transformation/__init__.py +13 -0
  279. customer_retention/stages/transformation/binary_handler.py +85 -0
  280. customer_retention/stages/transformation/categorical_encoder.py +245 -0
  281. customer_retention/stages/transformation/datetime_transformer.py +97 -0
  282. customer_retention/stages/transformation/numeric_transformer.py +181 -0
  283. customer_retention/stages/transformation/pipeline.py +257 -0
  284. customer_retention/stages/validation/__init__.py +60 -0
  285. customer_retention/stages/validation/adversarial_scoring_validator.py +205 -0
  286. customer_retention/stages/validation/business_sense_gate.py +173 -0
  287. customer_retention/stages/validation/data_quality_gate.py +235 -0
  288. customer_retention/stages/validation/data_validators.py +511 -0
  289. customer_retention/stages/validation/feature_quality_gate.py +183 -0
  290. customer_retention/stages/validation/gates.py +117 -0
  291. customer_retention/stages/validation/leakage_gate.py +352 -0
  292. customer_retention/stages/validation/model_validity_gate.py +213 -0
  293. customer_retention/stages/validation/pipeline_validation_runner.py +264 -0
  294. customer_retention/stages/validation/quality_scorer.py +544 -0
  295. customer_retention/stages/validation/rule_generator.py +57 -0
  296. customer_retention/stages/validation/scoring_pipeline_validator.py +446 -0
  297. customer_retention/stages/validation/timeseries_detector.py +769 -0
  298. customer_retention/transforms/__init__.py +47 -0
  299. customer_retention/transforms/artifact_store.py +50 -0
  300. customer_retention/transforms/executor.py +157 -0
  301. customer_retention/transforms/fitted.py +92 -0
  302. customer_retention/transforms/ops.py +148 -0
@@ -0,0 +1,572 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "7074023b",
6
+ "metadata": {
7
+ "papermill": {
8
+ "duration": 0.002564,
9
+ "end_time": "2026-02-02T13:03:54.779668",
10
+ "exception": false,
11
+ "start_time": "2026-02-02T13:03:54.777104",
12
+ "status": "completed"
13
+ },
14
+ "tags": []
15
+ },
16
+ "source": [
17
+ "# Chapter 9: Business Alignment\n",
18
+ "\n",
19
+ "**Purpose:** Align data exploration with business objectives and constraints.\n",
20
+ "\n",
21
+ "**Outputs:**\n",
22
+ "- Business context documentation\n",
23
+ "- Success metrics definition\n",
24
+ "- Constraints and requirements\n",
25
+ "\n",
26
+ "---"
27
+ ]
28
+ },
29
+ {
30
+ "cell_type": "markdown",
31
+ "id": "6204d96d",
32
+ "metadata": {
33
+ "papermill": {
34
+ "duration": 0.001754,
35
+ "end_time": "2026-02-02T13:03:54.783320",
36
+ "exception": false,
37
+ "start_time": "2026-02-02T13:03:54.781566",
38
+ "status": "completed"
39
+ },
40
+ "tags": []
41
+ },
42
+ "source": [
43
+ "## 9.1 Setup"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": null,
49
+ "id": "36b7856f",
50
+ "metadata": {
51
+ "execution": {
52
+ "iopub.execute_input": "2026-02-02T13:03:54.788245Z",
53
+ "iopub.status.busy": "2026-02-02T13:03:54.788106Z",
54
+ "iopub.status.idle": "2026-02-02T13:03:56.567208Z",
55
+ "shell.execute_reply": "2026-02-02T13:03:56.566685Z"
56
+ },
57
+ "papermill": {
58
+ "duration": 1.782784,
59
+ "end_time": "2026-02-02T13:03:56.568124",
60
+ "exception": false,
61
+ "start_time": "2026-02-02T13:03:54.785340",
62
+ "status": "completed"
63
+ },
64
+ "tags": []
65
+ },
66
+ "outputs": [],
67
+ "source": [
68
+ "from customer_retention.analysis.notebook_progress import track_and_export_previous\n",
69
+ "track_and_export_previous(\"09_business_alignment.ipynb\")\n",
70
+ "\n",
71
+ "from customer_retention.analysis.auto_explorer import ExplorationFindings\n",
72
+ "from customer_retention.analysis.visualization import display_table\n",
73
+ "import pandas as pd\n",
74
+ "from customer_retention.core.config.experiments import FINDINGS_DIR, EXPERIMENTS_DIR, OUTPUT_DIR, setup_experiments_structure\n",
75
+ "from customer_retention.stages.temporal import TEMPORAL_METADATA_COLS\n"
76
+ ]
77
+ },
78
+ {
79
+ "cell_type": "code",
80
+ "execution_count": null,
81
+ "id": "820fd2e1",
82
+ "metadata": {
83
+ "execution": {
84
+ "iopub.execute_input": "2026-02-02T13:03:56.572098Z",
85
+ "iopub.status.busy": "2026-02-02T13:03:56.571946Z",
86
+ "iopub.status.idle": "2026-02-02T13:03:56.796802Z",
87
+ "shell.execute_reply": "2026-02-02T13:03:56.796402Z"
88
+ },
89
+ "papermill": {
90
+ "duration": 0.227756,
91
+ "end_time": "2026-02-02T13:03:56.797497",
92
+ "exception": false,
93
+ "start_time": "2026-02-02T13:03:56.569741",
94
+ "status": "completed"
95
+ },
96
+ "tags": []
97
+ },
98
+ "outputs": [],
99
+ "source": [
100
+ "# === CONFIGURATION ===\n",
101
+ "from pathlib import Path\n",
102
+ "\n",
103
+ "# FINDINGS_DIR imported from customer_retention.core.config.experiments\n",
104
+ "\n",
105
+ "findings_files = [f for f in FINDINGS_DIR.glob(\"*_findings.yaml\") if \"multi_dataset\" not in f.name]\n",
106
+ "if not findings_files:\n",
107
+ " raise FileNotFoundError(f\"No findings files found in {FINDINGS_DIR}. Run notebook 01 first.\")\n",
108
+ "\n",
109
+ "# Prefer aggregated findings (from 01d) over event-level findings\n",
110
+ "# Pattern: *_aggregated* in filename indicates aggregated data\n",
111
+ "aggregated_files = [f for f in findings_files if \"_aggregated\" in f.name]\n",
112
+ "non_aggregated_files = [f for f in findings_files if \"_aggregated\" not in f.name]\n",
113
+ "\n",
114
+ "if aggregated_files:\n",
115
+ " # Use most recent aggregated file\n",
116
+ " aggregated_files.sort(key=lambda f: f.stat().st_mtime, reverse=True)\n",
117
+ " FINDINGS_PATH = str(aggregated_files[0])\n",
118
+ " print(f\"Found {len(aggregated_files)} aggregated findings file(s)\")\n",
119
+ " print(f\"Using: {FINDINGS_PATH}\")\n",
120
+ " if non_aggregated_files:\n",
121
+ " print(f\" (Skipping {len(non_aggregated_files)} event-level findings)\")\n",
122
+ "else:\n",
123
+ " # Fall back to most recent non-aggregated file\n",
124
+ " non_aggregated_files.sort(key=lambda f: f.stat().st_mtime, reverse=True)\n",
125
+ " FINDINGS_PATH = str(non_aggregated_files[0])\n",
126
+ " print(f\"Found {len(findings_files)} findings file(s)\")\n",
127
+ " print(f\"Using: {FINDINGS_PATH}\")\n",
128
+ "\n",
129
+ "findings = ExplorationFindings.load(FINDINGS_PATH)\n",
130
+ "\n",
131
+ "print(f\"\\nLoaded findings for {findings.column_count} columns\")"
132
+ ]
133
+ },
134
+ {
135
+ "cell_type": "markdown",
136
+ "id": "9c6ad68b",
137
+ "metadata": {
138
+ "papermill": {
139
+ "duration": 0.001286,
140
+ "end_time": "2026-02-02T13:03:56.800501",
141
+ "exception": false,
142
+ "start_time": "2026-02-02T13:03:56.799215",
143
+ "status": "completed"
144
+ },
145
+ "tags": []
146
+ },
147
+ "source": [
148
+ "## 9.2 Business Context\n",
149
+ "\n",
150
+ "Define the business context for this project."
151
+ ]
152
+ },
153
+ {
154
+ "cell_type": "code",
155
+ "execution_count": null,
156
+ "id": "a947050e",
157
+ "metadata": {
158
+ "execution": {
159
+ "iopub.execute_input": "2026-02-02T13:03:56.804379Z",
160
+ "iopub.status.busy": "2026-02-02T13:03:56.804249Z",
161
+ "iopub.status.idle": "2026-02-02T13:03:56.806909Z",
162
+ "shell.execute_reply": "2026-02-02T13:03:56.806232Z"
163
+ },
164
+ "papermill": {
165
+ "duration": 0.00536,
166
+ "end_time": "2026-02-02T13:03:56.807553",
167
+ "exception": false,
168
+ "start_time": "2026-02-02T13:03:56.802193",
169
+ "status": "completed"
170
+ },
171
+ "tags": []
172
+ },
173
+ "outputs": [],
174
+ "source": [
175
+ "BUSINESS_CONTEXT = {\n",
176
+ " \"project_name\": \"Customer Churn Prediction\",\n",
177
+ " \"business_objective\": \"Reduce customer churn by 20% through proactive retention campaigns\",\n",
178
+ " \"stakeholders\": [\"Marketing Team\", \"Customer Success\", \"Data Science\"],\n",
179
+ " \"timeline\": \"Q1 2025\",\n",
180
+ " \"budget_constraints\": \"$50k for retention campaigns per month\"\n",
181
+ "}\n",
182
+ "\n",
183
+ "print(\"Business Context:\")\n",
184
+ "for key, value in BUSINESS_CONTEXT.items():\n",
185
+ " print(f\" {key}: {value}\")"
186
+ ]
187
+ },
188
+ {
189
+ "cell_type": "markdown",
190
+ "id": "947806c0",
191
+ "metadata": {
192
+ "papermill": {
193
+ "duration": 0.001199,
194
+ "end_time": "2026-02-02T13:03:56.810126",
195
+ "exception": false,
196
+ "start_time": "2026-02-02T13:03:56.808927",
197
+ "status": "completed"
198
+ },
199
+ "tags": []
200
+ },
201
+ "source": [
202
+ "## 9.3 Success Metrics"
203
+ ]
204
+ },
205
+ {
206
+ "cell_type": "code",
207
+ "execution_count": null,
208
+ "id": "aec679b2",
209
+ "metadata": {
210
+ "execution": {
211
+ "iopub.execute_input": "2026-02-02T13:03:56.813855Z",
212
+ "iopub.status.busy": "2026-02-02T13:03:56.813739Z",
213
+ "iopub.status.idle": "2026-02-02T13:03:56.821979Z",
214
+ "shell.execute_reply": "2026-02-02T13:03:56.821450Z"
215
+ },
216
+ "papermill": {
217
+ "duration": 0.010836,
218
+ "end_time": "2026-02-02T13:03:56.822560",
219
+ "exception": false,
220
+ "start_time": "2026-02-02T13:03:56.811724",
221
+ "status": "completed"
222
+ },
223
+ "tags": []
224
+ },
225
+ "outputs": [],
226
+ "source": [
227
+ "SUCCESS_METRICS = [\n",
228
+ " {\n",
229
+ " \"Metric\": \"Model AUC\",\n",
230
+ " \"Target\": \">= 0.80\",\n",
231
+ " \"Priority\": \"High\",\n",
232
+ " \"Rationale\": \"Need strong discrimination to prioritize high-risk customers\"\n",
233
+ " },\n",
234
+ " {\n",
235
+ " \"Metric\": \"Precision at 20%\",\n",
236
+ " \"Target\": \">= 0.60\",\n",
237
+ " \"Priority\": \"High\",\n",
238
+ " \"Rationale\": \"Limited budget means we can only target top 20% of predictions\"\n",
239
+ " },\n",
240
+ " {\n",
241
+ " \"Metric\": \"Churn Rate Reduction\",\n",
242
+ " \"Target\": \"20%\",\n",
243
+ " \"Priority\": \"High\",\n",
244
+ " \"Rationale\": \"Primary business objective\"\n",
245
+ " },\n",
246
+ " {\n",
247
+ " \"Metric\": \"Model Latency\",\n",
248
+ " \"Target\": \"< 100ms\",\n",
249
+ " \"Priority\": \"Medium\",\n",
250
+ " \"Rationale\": \"Required for real-time scoring\"\n",
251
+ " },\n",
252
+ " {\n",
253
+ " \"Metric\": \"Fairness (Demographic Parity)\",\n",
254
+ " \"Target\": \"Ratio >= 0.8\",\n",
255
+ " \"Priority\": \"Medium\",\n",
256
+ " \"Rationale\": \"Ensure equitable treatment across segments\"\n",
257
+ " }\n",
258
+ "]\n",
259
+ "\n",
260
+ "metrics_df = pd.DataFrame(SUCCESS_METRICS)\n",
261
+ "print(\"Success Metrics:\")\n",
262
+ "display(metrics_df)"
263
+ ]
264
+ },
265
+ {
266
+ "cell_type": "markdown",
267
+ "id": "5dc340a7",
268
+ "metadata": {
269
+ "papermill": {
270
+ "duration": 0.001352,
271
+ "end_time": "2026-02-02T13:03:56.825447",
272
+ "exception": false,
273
+ "start_time": "2026-02-02T13:03:56.824095",
274
+ "status": "completed"
275
+ },
276
+ "tags": []
277
+ },
278
+ "source": [
279
+ "## 9.4 Deployment Requirements"
280
+ ]
281
+ },
282
+ {
283
+ "cell_type": "code",
284
+ "execution_count": null,
285
+ "id": "27e74568",
286
+ "metadata": {
287
+ "execution": {
288
+ "iopub.execute_input": "2026-02-02T13:03:56.829419Z",
289
+ "iopub.status.busy": "2026-02-02T13:03:56.829310Z",
290
+ "iopub.status.idle": "2026-02-02T13:03:56.832011Z",
291
+ "shell.execute_reply": "2026-02-02T13:03:56.831338Z"
292
+ },
293
+ "papermill": {
294
+ "duration": 0.005715,
295
+ "end_time": "2026-02-02T13:03:56.832732",
296
+ "exception": false,
297
+ "start_time": "2026-02-02T13:03:56.827017",
298
+ "status": "completed"
299
+ },
300
+ "tags": []
301
+ },
302
+ "outputs": [],
303
+ "source": [
304
+ "DEPLOYMENT_REQUIREMENTS = {\n",
305
+ " \"scoring_mode\": \"Both batch and real-time\",\n",
306
+ " \"batch_frequency\": \"Daily\",\n",
307
+ " \"real_time_latency\": \"< 100ms p99\",\n",
308
+ " \"infrastructure\": \"Databricks\",\n",
309
+ " \"model_registry\": \"MLflow\",\n",
310
+ " \"monitoring\": \"Required - drift detection and performance tracking\",\n",
311
+ " \"retraining\": \"Monthly or on significant drift\"\n",
312
+ "}\n",
313
+ "\n",
314
+ "print(\"Deployment Requirements:\")\n",
315
+ "for key, value in DEPLOYMENT_REQUIREMENTS.items():\n",
316
+ " print(f\" {key}: {value}\")"
317
+ ]
318
+ },
319
+ {
320
+ "cell_type": "markdown",
321
+ "id": "154da6ba",
322
+ "metadata": {
323
+ "papermill": {
324
+ "duration": 0.00148,
325
+ "end_time": "2026-02-02T13:03:56.835906",
326
+ "exception": false,
327
+ "start_time": "2026-02-02T13:03:56.834426",
328
+ "status": "completed"
329
+ },
330
+ "tags": []
331
+ },
332
+ "source": [
333
+ "## 9.5 Data Constraints"
334
+ ]
335
+ },
336
+ {
337
+ "cell_type": "code",
338
+ "execution_count": null,
339
+ "id": "f6682f6e",
340
+ "metadata": {
341
+ "execution": {
342
+ "iopub.execute_input": "2026-02-02T13:03:56.839748Z",
343
+ "iopub.status.busy": "2026-02-02T13:03:56.839615Z",
344
+ "iopub.status.idle": "2026-02-02T13:03:56.844180Z",
345
+ "shell.execute_reply": "2026-02-02T13:03:56.843643Z"
346
+ },
347
+ "papermill": {
348
+ "duration": 0.007327,
349
+ "end_time": "2026-02-02T13:03:56.844666",
350
+ "exception": false,
351
+ "start_time": "2026-02-02T13:03:56.837339",
352
+ "status": "completed"
353
+ },
354
+ "tags": []
355
+ },
356
+ "outputs": [],
357
+ "source": [
358
+ "DATA_CONSTRAINTS = [\n",
359
+ " {\n",
360
+ " \"Constraint\": \"PII Handling\",\n",
361
+ " \"Requirement\": \"No direct PII in features (names, SSN, etc.)\",\n",
362
+ " \"Status\": \"To verify\"\n",
363
+ " },\n",
364
+ " {\n",
365
+ " \"Constraint\": \"Data Freshness\",\n",
366
+ " \"Requirement\": \"Features must be available within 24 hours\",\n",
367
+ " \"Status\": \"To verify\"\n",
368
+ " },\n",
369
+ " {\n",
370
+ " \"Constraint\": \"Historical Depth\",\n",
371
+ " \"Requirement\": \"Minimum 12 months of history for training\",\n",
372
+ " \"Status\": \"To verify\"\n",
373
+ " },\n",
374
+ " {\n",
375
+ " \"Constraint\": \"Protected Attributes\",\n",
376
+ " \"Requirement\": \"Age, gender, race should not be direct features\",\n",
377
+ " \"Status\": \"To verify\"\n",
378
+ " }\n",
379
+ "]\n",
380
+ "\n",
381
+ "constraints_df = pd.DataFrame(DATA_CONSTRAINTS)\n",
382
+ "print(\"Data Constraints:\")\n",
383
+ "display(constraints_df)"
384
+ ]
385
+ },
386
+ {
387
+ "cell_type": "markdown",
388
+ "id": "dadb506b",
389
+ "metadata": {
390
+ "papermill": {
391
+ "duration": 0.00146,
392
+ "end_time": "2026-02-02T13:03:56.847876",
393
+ "exception": false,
394
+ "start_time": "2026-02-02T13:03:56.846416",
395
+ "status": "completed"
396
+ },
397
+ "tags": []
398
+ },
399
+ "source": [
400
+ "## 9.6 Intervention Strategy"
401
+ ]
402
+ },
403
+ {
404
+ "cell_type": "code",
405
+ "execution_count": null,
406
+ "id": "97c21062",
407
+ "metadata": {
408
+ "execution": {
409
+ "iopub.execute_input": "2026-02-02T13:03:56.851591Z",
410
+ "iopub.status.busy": "2026-02-02T13:03:56.851490Z",
411
+ "iopub.status.idle": "2026-02-02T13:03:56.855665Z",
412
+ "shell.execute_reply": "2026-02-02T13:03:56.855228Z"
413
+ },
414
+ "papermill": {
415
+ "duration": 0.007099,
416
+ "end_time": "2026-02-02T13:03:56.856357",
417
+ "exception": false,
418
+ "start_time": "2026-02-02T13:03:56.849258",
419
+ "status": "completed"
420
+ },
421
+ "tags": []
422
+ },
423
+ "outputs": [],
424
+ "source": [
425
+ "INTERVENTIONS = [\n",
426
+ " {\n",
427
+ " \"Risk Level\": \"High (>0.8)\",\n",
428
+ " \"Intervention\": \"Personal call from account manager\",\n",
429
+ " \"Cost\": \"$50/customer\",\n",
430
+ " \"Expected Effectiveness\": \"40% retention\"\n",
431
+ " },\n",
432
+ " {\n",
433
+ " \"Risk Level\": \"Medium (0.5-0.8)\",\n",
434
+ " \"Intervention\": \"Personalized email + discount offer\",\n",
435
+ " \"Cost\": \"$10/customer\",\n",
436
+ " \"Expected Effectiveness\": \"20% retention\"\n",
437
+ " },\n",
438
+ " {\n",
439
+ " \"Risk Level\": \"Low (<0.5)\",\n",
440
+ " \"Intervention\": \"Automated engagement email\",\n",
441
+ " \"Cost\": \"$0.50/customer\",\n",
442
+ " \"Expected Effectiveness\": \"5% retention\"\n",
443
+ " }\n",
444
+ "]\n",
445
+ "\n",
446
+ "interventions_df = pd.DataFrame(INTERVENTIONS)\n",
447
+ "print(\"Intervention Strategy:\")\n",
448
+ "display(interventions_df)"
449
+ ]
450
+ },
451
+ {
452
+ "cell_type": "markdown",
453
+ "id": "d54fd4f3",
454
+ "metadata": {
455
+ "papermill": {
456
+ "duration": 0.00165,
457
+ "end_time": "2026-02-02T13:03:56.859839",
458
+ "exception": false,
459
+ "start_time": "2026-02-02T13:03:56.858189",
460
+ "status": "completed"
461
+ },
462
+ "tags": []
463
+ },
464
+ "source": [
465
+ "## 9.7 Save Business Context to Findings"
466
+ ]
467
+ },
468
+ {
469
+ "cell_type": "code",
470
+ "execution_count": null,
471
+ "id": "6cba5547",
472
+ "metadata": {
473
+ "execution": {
474
+ "iopub.execute_input": "2026-02-02T13:03:56.864013Z",
475
+ "iopub.status.busy": "2026-02-02T13:03:56.863903Z",
476
+ "iopub.status.idle": "2026-02-02T13:03:56.938199Z",
477
+ "shell.execute_reply": "2026-02-02T13:03:56.937543Z"
478
+ },
479
+ "papermill": {
480
+ "duration": 0.077367,
481
+ "end_time": "2026-02-02T13:03:56.938923",
482
+ "exception": false,
483
+ "start_time": "2026-02-02T13:03:56.861556",
484
+ "status": "completed"
485
+ },
486
+ "tags": []
487
+ },
488
+ "outputs": [],
489
+ "source": [
490
+ "findings.metadata = findings.metadata or {}\n",
491
+ "findings.metadata[\"business_context\"] = BUSINESS_CONTEXT\n",
492
+ "findings.metadata[\"success_metrics\"] = SUCCESS_METRICS\n",
493
+ "findings.metadata[\"deployment_requirements\"] = DEPLOYMENT_REQUIREMENTS\n",
494
+ "\n",
495
+ "findings.save(FINDINGS_PATH)\n",
496
+ "print(f\"Business context saved to: {FINDINGS_PATH}\")\n"
497
+ ]
498
+ },
499
+ {
500
+ "cell_type": "markdown",
501
+ "id": "18808635",
502
+ "metadata": {
503
+ "papermill": {
504
+ "duration": 0.012662,
505
+ "end_time": "2026-02-02T13:03:56.953575",
506
+ "exception": false,
507
+ "start_time": "2026-02-02T13:03:56.940913",
508
+ "status": "completed"
509
+ },
510
+ "tags": []
511
+ },
512
+ "source": [
513
+ "---\n",
514
+ "\n",
515
+ "## Next Steps\n",
516
+ "\n",
517
+ "Continue to **10_spec_generation.ipynb** to generate production specifications."
518
+ ]
519
+ },
520
+ {
521
+ "cell_type": "markdown",
522
+ "id": "f0b54317",
523
+ "metadata": {
524
+ "papermill": {
525
+ "duration": 0.01307,
526
+ "end_time": "2026-02-02T13:03:56.974482",
527
+ "exception": false,
528
+ "start_time": "2026-02-02T13:03:56.961412",
529
+ "status": "completed"
530
+ },
531
+ "tags": []
532
+ },
533
+ "source": [
534
+ "> **Save Reminder:** Save this notebook (Ctrl+S / Cmd+S) before running the next one.\n",
535
+ "> The next notebook will automatically export this notebook's HTML documentation from the saved file."
536
+ ]
537
+ }
538
+ ],
539
+ "metadata": {
540
+ "kernelspec": {
541
+ "display_name": "Python 3",
542
+ "language": "python",
543
+ "name": "python3"
544
+ },
545
+ "language_info": {
546
+ "codemirror_mode": {
547
+ "name": "ipython",
548
+ "version": 3
549
+ },
550
+ "file_extension": ".py",
551
+ "mimetype": "text/x-python",
552
+ "name": "python",
553
+ "nbconvert_exporter": "python",
554
+ "pygments_lexer": "ipython3",
555
+ "version": "3.12.4"
556
+ },
557
+ "papermill": {
558
+ "default_parameters": {},
559
+ "duration": 5.393777,
560
+ "end_time": "2026-02-02T13:03:59.592619",
561
+ "environment_variables": {},
562
+ "exception": null,
563
+ "input_path": "/Users/Vital/python/CustomerRetention/exploration_notebooks/09_business_alignment.ipynb",
564
+ "output_path": "/Users/Vital/python/CustomerRetention/exploration_notebooks/09_business_alignment.ipynb",
565
+ "parameters": {},
566
+ "start_time": "2026-02-02T13:03:54.198842",
567
+ "version": "2.6.0"
568
+ }
569
+ },
570
+ "nbformat": 4,
571
+ "nbformat_minor": 5
572
+ }