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,679 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "cell-0",
6
+ "metadata": {
7
+ "papermill": {
8
+ "duration": 0.002487,
9
+ "end_time": "2026-02-02T13:00:52.603186",
10
+ "exception": false,
11
+ "start_time": "2026-02-02T13:00:52.600699",
12
+ "status": "completed"
13
+ },
14
+ "tags": []
15
+ },
16
+ "source": [
17
+ "# Chapter 1b: Temporal Quality Assessment (Event Bronze Track)\n",
18
+ "\n",
19
+ "**Purpose:** Run quality checks specific to event-level datasets to identify data issues before feature engineering.\n",
20
+ "\n",
21
+ "**When to use this notebook:**\n",
22
+ "- After completing 01a_temporal_deep_dive.ipynb\n",
23
+ "- Your dataset is EVENT_LEVEL granularity\n",
24
+ "- You want to validate temporal data integrity before aggregation\n",
25
+ "\n",
26
+ "| Check | What It Detects | Why It Matters for ML |\n",
27
+ "|-------|-----------------|----------------------|\n",
28
+ "| **TQ001** | Duplicate events (same entity + timestamp) | Inflates counts, skews aggregations, creates artificial sequence patterns |\n",
29
+ "| **TQ002** | Unexpected temporal gaps | Rolling features become misleading; \"events in last 30d\" drops during gaps |\n",
30
+ "| **TQ003** | Future dates | Data leakage — model sees future during training |\n",
31
+ "| **TQ004** | Ambiguous event ordering | Sequence features undefined when multiple events share timestamp |"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "markdown",
36
+ "id": "cell-1",
37
+ "metadata": {
38
+ "papermill": {
39
+ "duration": 0.00158,
40
+ "end_time": "2026-02-02T13:00:52.606755",
41
+ "exception": false,
42
+ "start_time": "2026-02-02T13:00:52.605175",
43
+ "status": "completed"
44
+ },
45
+ "tags": []
46
+ },
47
+ "source": [
48
+ "## 1b.1 Load Findings and Data"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": null,
54
+ "id": "cell-2",
55
+ "metadata": {
56
+ "execution": {
57
+ "iopub.execute_input": "2026-02-02T13:00:52.611011Z",
58
+ "iopub.status.busy": "2026-02-02T13:00:52.610876Z",
59
+ "iopub.status.idle": "2026-02-02T13:00:54.504186Z",
60
+ "shell.execute_reply": "2026-02-02T13:00:54.503492Z"
61
+ },
62
+ "papermill": {
63
+ "duration": 1.896686,
64
+ "end_time": "2026-02-02T13:00:54.505137",
65
+ "exception": false,
66
+ "start_time": "2026-02-02T13:00:52.608451",
67
+ "status": "completed"
68
+ },
69
+ "tags": []
70
+ },
71
+ "outputs": [],
72
+ "source": [
73
+ "from customer_retention.analysis.notebook_progress import track_and_export_previous\n",
74
+ "track_and_export_previous(\"01b_temporal_quality.ipynb\")\n",
75
+ "\n",
76
+ "from pathlib import Path\n",
77
+ "import pandas as pd\n",
78
+ "import plotly.graph_objects as go\n",
79
+ "from plotly.subplots import make_subplots\n",
80
+ "\n",
81
+ "from customer_retention.analysis.auto_explorer import ExplorationFindings, RecommendationEngine\n",
82
+ "from customer_retention.analysis.visualization import ChartBuilder, display_figure\n",
83
+ "from customer_retention.core.config.column_config import ColumnType\n",
84
+ "from customer_retention.stages.profiling import (\n",
85
+ " DuplicateEventCheck, TemporalGapCheck, FutureDateCheck, EventOrderCheck,\n",
86
+ " TemporalQualityReporter, SegmentAwareOutlierAnalyzer\n",
87
+ ")\n",
88
+ "from customer_retention.stages.temporal import load_data_with_snapshot_preference, TEMPORAL_METADATA_COLS\n",
89
+ "from customer_retention.core.config.experiments import FINDINGS_DIR, EXPERIMENTS_DIR, OUTPUT_DIR, setup_experiments_structure\n"
90
+ ]
91
+ },
92
+ {
93
+ "cell_type": "code",
94
+ "execution_count": null,
95
+ "id": "cell-3",
96
+ "metadata": {
97
+ "execution": {
98
+ "iopub.execute_input": "2026-02-02T13:00:54.509631Z",
99
+ "iopub.status.busy": "2026-02-02T13:00:54.509304Z",
100
+ "iopub.status.idle": "2026-02-02T13:00:55.198236Z",
101
+ "shell.execute_reply": "2026-02-02T13:00:55.197651Z"
102
+ },
103
+ "papermill": {
104
+ "duration": 0.692154,
105
+ "end_time": "2026-02-02T13:00:55.199216",
106
+ "exception": false,
107
+ "start_time": "2026-02-02T13:00:54.507062",
108
+ "status": "completed"
109
+ },
110
+ "tags": []
111
+ },
112
+ "outputs": [],
113
+ "source": [
114
+ "# FINDINGS_DIR imported from customer_retention.core.config.experiments\n",
115
+ "findings_files = sorted(\n",
116
+ " [f for f in FINDINGS_DIR.glob(\"*_findings.yaml\") if \"multi_dataset\" not in f.name],\n",
117
+ " key=lambda f: f.stat().st_mtime, reverse=True\n",
118
+ ")\n",
119
+ "if not findings_files:\n",
120
+ " raise FileNotFoundError(f\"No findings in {FINDINGS_DIR}. Run notebook 01 first.\")\n",
121
+ "\n",
122
+ "FINDINGS_PATH = str(findings_files[0])\n",
123
+ "findings = ExplorationFindings.load(FINDINGS_PATH)\n",
124
+ "print(f\"Using: {FINDINGS_PATH}\")\n",
125
+ "\n",
126
+ "ts_meta = findings.time_series_metadata\n",
127
+ "ENTITY_COLUMN, TIME_COLUMN = ts_meta.entity_column, ts_meta.time_column\n",
128
+ "print(f\"Entity: {ENTITY_COLUMN}, Time: {TIME_COLUMN}\")\n",
129
+ "\n",
130
+ "df, data_source = load_data_with_snapshot_preference(findings, output_dir=str(FINDINGS_DIR))\n",
131
+ "charts = ChartBuilder()\n",
132
+ "print(f\"Loaded {len(df):,} rows ({data_source})\")"
133
+ ]
134
+ },
135
+ {
136
+ "cell_type": "markdown",
137
+ "id": "cell-4",
138
+ "metadata": {
139
+ "papermill": {
140
+ "duration": 0.0014,
141
+ "end_time": "2026-02-02T13:00:55.202447",
142
+ "exception": false,
143
+ "start_time": "2026-02-02T13:00:55.201047",
144
+ "status": "completed"
145
+ },
146
+ "tags": []
147
+ },
148
+ "source": [
149
+ "## 1b.2 Configure Quality Checks"
150
+ ]
151
+ },
152
+ {
153
+ "cell_type": "code",
154
+ "execution_count": null,
155
+ "id": "cell-5",
156
+ "metadata": {
157
+ "execution": {
158
+ "iopub.execute_input": "2026-02-02T13:00:55.206889Z",
159
+ "iopub.status.busy": "2026-02-02T13:00:55.206640Z",
160
+ "iopub.status.idle": "2026-02-02T13:00:55.209364Z",
161
+ "shell.execute_reply": "2026-02-02T13:00:55.208747Z"
162
+ },
163
+ "papermill": {
164
+ "duration": 0.005584,
165
+ "end_time": "2026-02-02T13:00:55.209814",
166
+ "exception": false,
167
+ "start_time": "2026-02-02T13:00:55.204230",
168
+ "status": "completed"
169
+ },
170
+ "tags": []
171
+ },
172
+ "outputs": [],
173
+ "source": [
174
+ "REFERENCE_DATE = pd.Timestamp.now() # or pd.Timestamp(\"2024-01-01\")\n",
175
+ "EXPECTED_FREQUENCY = \"D\" # D=daily, W=weekly, M=monthly, H=hourly\n",
176
+ "MAX_GAP_MULTIPLE = 3.0\n",
177
+ "\n",
178
+ "print(f\"Reference: {REFERENCE_DATE.date()}, Frequency: {EXPECTED_FREQUENCY}, Gap threshold: {MAX_GAP_MULTIPLE}x\")"
179
+ ]
180
+ },
181
+ {
182
+ "cell_type": "markdown",
183
+ "id": "cell-6",
184
+ "metadata": {
185
+ "papermill": {
186
+ "duration": 0.001492,
187
+ "end_time": "2026-02-02T13:00:55.213170",
188
+ "exception": false,
189
+ "start_time": "2026-02-02T13:00:55.211678",
190
+ "status": "completed"
191
+ },
192
+ "tags": []
193
+ },
194
+ "source": [
195
+ "## 1b.3 Run Temporal Quality Checks\n",
196
+ "\n",
197
+ "| Issue Type | ML Impact | Mitigation |\n",
198
+ "|------------|-----------|------------|\n",
199
+ "| Duplicates | Sum/count features inflated; artificial patterns in sequences | Deduplicate or add sequence index |\n",
200
+ "| Gaps | Rolling aggregations drop; recency features spike | Document gaps; add gap indicator feature |\n",
201
+ "| Future dates | Model trains on leaked future info | Filter to reference date; check timezone handling |\n",
202
+ "| Ordering | \"Previous event\" features undefined | Add tiebreaker column; use stable sort |"
203
+ ]
204
+ },
205
+ {
206
+ "cell_type": "code",
207
+ "execution_count": null,
208
+ "id": "cell-7",
209
+ "metadata": {
210
+ "execution": {
211
+ "iopub.execute_input": "2026-02-02T13:00:55.217026Z",
212
+ "iopub.status.busy": "2026-02-02T13:00:55.216922Z",
213
+ "iopub.status.idle": "2026-02-02T13:00:55.267263Z",
214
+ "shell.execute_reply": "2026-02-02T13:00:55.266748Z"
215
+ },
216
+ "papermill": {
217
+ "duration": 0.053177,
218
+ "end_time": "2026-02-02T13:00:55.267824",
219
+ "exception": false,
220
+ "start_time": "2026-02-02T13:00:55.214647",
221
+ "status": "completed"
222
+ },
223
+ "tags": []
224
+ },
225
+ "outputs": [],
226
+ "source": [
227
+ "checks = [\n",
228
+ " DuplicateEventCheck(entity_column=ENTITY_COLUMN, time_column=TIME_COLUMN),\n",
229
+ " TemporalGapCheck(time_column=TIME_COLUMN, expected_frequency=EXPECTED_FREQUENCY, max_gap_multiple=MAX_GAP_MULTIPLE),\n",
230
+ " FutureDateCheck(time_column=TIME_COLUMN, reference_date=REFERENCE_DATE),\n",
231
+ " EventOrderCheck(entity_column=ENTITY_COLUMN, time_column=TIME_COLUMN),\n",
232
+ "]\n",
233
+ "results = [check.run(df) for check in checks]\n",
234
+ "reporter = TemporalQualityReporter(results, len(df))\n",
235
+ "reporter.print_results()"
236
+ ]
237
+ },
238
+ {
239
+ "cell_type": "markdown",
240
+ "id": "cell-8",
241
+ "metadata": {
242
+ "papermill": {
243
+ "duration": 0.001479,
244
+ "end_time": "2026-02-02T13:00:55.270977",
245
+ "exception": false,
246
+ "start_time": "2026-02-02T13:00:55.269498",
247
+ "status": "completed"
248
+ },
249
+ "tags": []
250
+ },
251
+ "source": [
252
+ "## 1b.4 Quality Score\n",
253
+ "\n",
254
+ "| Component | Weight | Scoring Logic |\n",
255
+ "|-----------|--------|---------------|\n",
256
+ "| Each check | 25% | 100 if no issues; deductions proportional to % affected |\n",
257
+ "| Grade A | 90-100 | Proceed with confidence |\n",
258
+ "| Grade B | 75-89 | Document issues, proceed with caution |\n",
259
+ "| Grade C | 60-74 | Address issues before feature engineering |\n",
260
+ "| Grade D | <60 | Investigation required |"
261
+ ]
262
+ },
263
+ {
264
+ "cell_type": "code",
265
+ "execution_count": null,
266
+ "id": "cell-9",
267
+ "metadata": {
268
+ "execution": {
269
+ "iopub.execute_input": "2026-02-02T13:00:55.275294Z",
270
+ "iopub.status.busy": "2026-02-02T13:00:55.275192Z",
271
+ "iopub.status.idle": "2026-02-02T13:00:55.277551Z",
272
+ "shell.execute_reply": "2026-02-02T13:00:55.276851Z"
273
+ },
274
+ "papermill": {
275
+ "duration": 0.005227,
276
+ "end_time": "2026-02-02T13:00:55.278101",
277
+ "exception": false,
278
+ "start_time": "2026-02-02T13:00:55.272874",
279
+ "status": "completed"
280
+ },
281
+ "tags": []
282
+ },
283
+ "outputs": [],
284
+ "source": [
285
+ "reporter.print_score()\n",
286
+ "quality_score, grade, passed = reporter.quality_score, reporter.grade, reporter.passed"
287
+ ]
288
+ },
289
+ {
290
+ "cell_type": "markdown",
291
+ "id": "cell-10",
292
+ "metadata": {
293
+ "papermill": {
294
+ "duration": 0.001615,
295
+ "end_time": "2026-02-02T13:00:55.281714",
296
+ "exception": false,
297
+ "start_time": "2026-02-02T13:00:55.280099",
298
+ "status": "completed"
299
+ },
300
+ "tags": []
301
+ },
302
+ "source": [
303
+ "## 1b.5 Event Volume Analysis\n",
304
+ "\n",
305
+ "| What to Look For | Indicates | Action |\n",
306
+ "|-----------------|-----------|--------|\n",
307
+ "| Missing bars | Data gaps (TQ002) | Document; add gap indicator |\n",
308
+ "| Declining trend | Population shrinkage or data cutoff | Check if intentional |\n",
309
+ "| Spikes | Campaigns, seasonality, or data issues | Investigate cause |\n",
310
+ "| Flat periods | Possible logging outages | Verify with data source |"
311
+ ]
312
+ },
313
+ {
314
+ "cell_type": "code",
315
+ "execution_count": null,
316
+ "id": "cell-11",
317
+ "metadata": {
318
+ "execution": {
319
+ "iopub.execute_input": "2026-02-02T13:00:55.286039Z",
320
+ "iopub.status.busy": "2026-02-02T13:00:55.285927Z",
321
+ "iopub.status.idle": "2026-02-02T13:00:55.315871Z",
322
+ "shell.execute_reply": "2026-02-02T13:00:55.315137Z"
323
+ },
324
+ "papermill": {
325
+ "duration": 0.033261,
326
+ "end_time": "2026-02-02T13:00:55.316776",
327
+ "exception": false,
328
+ "start_time": "2026-02-02T13:00:55.283515",
329
+ "status": "completed"
330
+ },
331
+ "tags": []
332
+ },
333
+ "outputs": [],
334
+ "source": [
335
+ "df_temp = df.copy()\n",
336
+ "df_temp[TIME_COLUMN] = pd.to_datetime(df_temp[TIME_COLUMN])\n",
337
+ "time_span = (df_temp[TIME_COLUMN].max() - df_temp[TIME_COLUMN].min()).days\n",
338
+ "\n",
339
+ "freq, label = (\"D\", \"Daily\") if time_span <= 90 else (\"W\", \"Weekly\") if time_span <= 365 else (\"ME\", \"Monthly\")\n",
340
+ "counts = df_temp.groupby(pd.Grouper(key=TIME_COLUMN, freq=freq)).size()\n",
341
+ "\n",
342
+ "fig = go.Figure(go.Bar(x=counts.index, y=counts.values, marker_color=\"#4682B4\"))\n",
343
+ "fig.update_layout(title=f\"{label} Event Volume (gaps = missing bars)\", height=300, template=\"plotly_white\")\n",
344
+ "display_figure(fig)"
345
+ ]
346
+ },
347
+ {
348
+ "cell_type": "markdown",
349
+ "id": "cell-14",
350
+ "metadata": {
351
+ "papermill": {
352
+ "duration": 0.003275,
353
+ "end_time": "2026-02-02T13:00:55.323645",
354
+ "exception": false,
355
+ "start_time": "2026-02-02T13:00:55.320370",
356
+ "status": "completed"
357
+ },
358
+ "tags": []
359
+ },
360
+ "source": [
361
+ "## 1b.6 Outlier Analysis\n",
362
+ "\n",
363
+ "| Approach | When to Use | Why It Matters |\n",
364
+ "|----------|-------------|----------------|\n",
365
+ "| Global detection | Homogeneous data | Simple threshold works |\n",
366
+ "| Segment-aware | Data has natural groups | Avoids false positives when segments have different scales |\n",
367
+ "\n",
368
+ "Segment-aware detection clusters entities by target (or other segment) and detects outliers within each group separately."
369
+ ]
370
+ },
371
+ {
372
+ "cell_type": "code",
373
+ "execution_count": null,
374
+ "id": "cell-15",
375
+ "metadata": {
376
+ "execution": {
377
+ "iopub.execute_input": "2026-02-02T13:00:55.331243Z",
378
+ "iopub.status.busy": "2026-02-02T13:00:55.331125Z",
379
+ "iopub.status.idle": "2026-02-02T13:01:05.464597Z",
380
+ "shell.execute_reply": "2026-02-02T13:01:05.463713Z"
381
+ },
382
+ "papermill": {
383
+ "duration": 10.138458,
384
+ "end_time": "2026-02-02T13:01:05.465385",
385
+ "exception": false,
386
+ "start_time": "2026-02-02T13:00:55.326927",
387
+ "status": "completed"
388
+ },
389
+ "tags": []
390
+ },
391
+ "outputs": [],
392
+ "source": [
393
+ "numeric_cols = [n for n, c in findings.columns.items()\n",
394
+ " if c.inferred_type in [ColumnType.NUMERIC_CONTINUOUS, ColumnType.NUMERIC_DISCRETE]\n",
395
+ " and n not in [ENTITY_COLUMN, TIME_COLUMN] and n not in TEMPORAL_METADATA_COLS]\n",
396
+ "\n",
397
+ "if numeric_cols:\n",
398
+ " analyzer = SegmentAwareOutlierAnalyzer(max_segments=5)\n",
399
+ " result = analyzer.analyze(df, feature_cols=numeric_cols, segment_col=None, target_col=findings.target_column)\n",
400
+ " \n",
401
+ " print(f\"Segments detected: {result.n_segments}\")\n",
402
+ " if result.n_segments > 1:\n",
403
+ " data = [{\"Feature\": c, \"Global\": result.global_analysis[c].outliers_detected,\n",
404
+ " \"Segment\": sum(s[c].outliers_detected for s in result.segment_analysis.values() if c in s)}\n",
405
+ " for c in numeric_cols]\n",
406
+ " display(pd.DataFrame(data))\n",
407
+ " if result.segmentation_recommended:\n",
408
+ " print(\"\\n💡 Segment-specific outlier treatment recommended\")\n",
409
+ " else:\n",
410
+ " print(\"Data appears homogeneous - using global outlier detection\")\n",
411
+ "else:\n",
412
+ " print(\"No numeric columns for outlier analysis.\")"
413
+ ]
414
+ },
415
+ {
416
+ "cell_type": "markdown",
417
+ "id": "cell-16",
418
+ "metadata": {
419
+ "papermill": {
420
+ "duration": 0.003472,
421
+ "end_time": "2026-02-02T13:01:05.472843",
422
+ "exception": false,
423
+ "start_time": "2026-02-02T13:01:05.469371",
424
+ "status": "completed"
425
+ },
426
+ "tags": []
427
+ },
428
+ "source": [
429
+ "## 1b.7 Data Validation\n",
430
+ "\n",
431
+ "| Check | Issue | Impact |\n",
432
+ "|-------|-------|--------|\n",
433
+ "| Binary fields | Values outside {0, 1} | Model crashes or silent errors |\n",
434
+ "| String consistency | Case/spacing variants (\"Yes\" vs \"yes\") | Inflated cardinality; split categories |\n",
435
+ "| Missing patterns | Systematic missingness | Bias in imputation |"
436
+ ]
437
+ },
438
+ {
439
+ "cell_type": "code",
440
+ "execution_count": null,
441
+ "id": "cell-17",
442
+ "metadata": {
443
+ "execution": {
444
+ "iopub.execute_input": "2026-02-02T13:01:05.481150Z",
445
+ "iopub.status.busy": "2026-02-02T13:01:05.481017Z",
446
+ "iopub.status.idle": "2026-02-02T13:01:05.648331Z",
447
+ "shell.execute_reply": "2026-02-02T13:01:05.647595Z"
448
+ },
449
+ "papermill": {
450
+ "duration": 0.172374,
451
+ "end_time": "2026-02-02T13:01:05.649066",
452
+ "exception": false,
453
+ "start_time": "2026-02-02T13:01:05.476692",
454
+ "status": "completed"
455
+ },
456
+ "tags": []
457
+ },
458
+ "outputs": [],
459
+ "source": [
460
+ "# Binary field validation\n",
461
+ "binary_cols = [n for n, c in findings.columns.items() if c.inferred_type == ColumnType.BINARY and n not in TEMPORAL_METADATA_COLS]\n",
462
+ "for col in binary_cols:\n",
463
+ " c0, c1 = (df[col] == 0).sum(), (df[col] == 1).sum()\n",
464
+ " print(f\"✓ {col}: 0={c0:,} ({c0/(c0+c1)*100:.1f}%), 1={c1:,} ({c1/(c0+c1)*100:.1f}%)\")\n",
465
+ "\n",
466
+ "# Consistency check\n",
467
+ "issues = []\n",
468
+ "for col in df.select_dtypes(include=['object']).columns:\n",
469
+ " if col in [ENTITY_COLUMN, TIME_COLUMN]: continue\n",
470
+ " variants = {}\n",
471
+ " for v in df[col].dropna().unique():\n",
472
+ " key = str(v).lower().strip()\n",
473
+ " variants.setdefault(key, []).append(v)\n",
474
+ " issues.extend([{\"Column\": col, \"Variants\": vs} for vs in variants.values() if len(vs) > 1])\n",
475
+ "\n",
476
+ "print(f\"\\n{'⚠️ Consistency issues: ' + str(len(issues)) if issues else '✅ No consistency issues'}\")"
477
+ ]
478
+ },
479
+ {
480
+ "cell_type": "markdown",
481
+ "id": "cell-18",
482
+ "metadata": {
483
+ "papermill": {
484
+ "duration": 0.003229,
485
+ "end_time": "2026-02-02T13:01:05.655939",
486
+ "exception": false,
487
+ "start_time": "2026-02-02T13:01:05.652710",
488
+ "status": "completed"
489
+ },
490
+ "tags": []
491
+ },
492
+ "source": [
493
+ "## 1b.8 Recommendations\n",
494
+ "\n",
495
+ "Framework-generated recommendations based on column-level issues detected during exploration."
496
+ ]
497
+ },
498
+ {
499
+ "cell_type": "code",
500
+ "execution_count": null,
501
+ "id": "cell-19",
502
+ "metadata": {
503
+ "execution": {
504
+ "iopub.execute_input": "2026-02-02T13:01:05.663919Z",
505
+ "iopub.status.busy": "2026-02-02T13:01:05.663801Z",
506
+ "iopub.status.idle": "2026-02-02T13:01:05.667016Z",
507
+ "shell.execute_reply": "2026-02-02T13:01:05.666376Z"
508
+ },
509
+ "papermill": {
510
+ "duration": 0.00802,
511
+ "end_time": "2026-02-02T13:01:05.667651",
512
+ "exception": false,
513
+ "start_time": "2026-02-02T13:01:05.659631",
514
+ "status": "completed"
515
+ },
516
+ "tags": []
517
+ },
518
+ "outputs": [],
519
+ "source": [
520
+ "rec_engine = RecommendationEngine()\n",
521
+ "recs = rec_engine.recommend_cleaning(findings)\n",
522
+ "\n",
523
+ "if recs:\n",
524
+ " for r in sorted(recs, key=lambda x: {\"high\": 0, \"medium\": 1, \"low\": 2}.get(x.severity, 3)):\n",
525
+ " icon = {\"high\": \"🔴\", \"medium\": \"🟡\", \"low\": \"🟢\"}.get(r.severity, \"⚪\")\n",
526
+ " print(f\"{icon} [{r.severity.upper()}] {r.column_name}: {r.description}\")\n",
527
+ " label = r.strategy_label if r.strategy_label else r.strategy.replace(\"_\", \" \").title()\n",
528
+ " print(f\" Strategy: {label}\")\n",
529
+ "else:\n",
530
+ " print(\"✅ No critical cleaning recommendations\")"
531
+ ]
532
+ },
533
+ {
534
+ "cell_type": "markdown",
535
+ "id": "cell-20",
536
+ "metadata": {
537
+ "papermill": {
538
+ "duration": 0.004024,
539
+ "end_time": "2026-02-02T13:01:05.675373",
540
+ "exception": false,
541
+ "start_time": "2026-02-02T13:01:05.671349",
542
+ "status": "completed"
543
+ },
544
+ "tags": []
545
+ },
546
+ "source": [
547
+ "## 1b.9 Save Results"
548
+ ]
549
+ },
550
+ {
551
+ "cell_type": "code",
552
+ "execution_count": null,
553
+ "id": "cell-21",
554
+ "metadata": {
555
+ "execution": {
556
+ "iopub.execute_input": "2026-02-02T13:01:05.683302Z",
557
+ "iopub.status.busy": "2026-02-02T13:01:05.683171Z",
558
+ "iopub.status.idle": "2026-02-02T13:01:05.699141Z",
559
+ "shell.execute_reply": "2026-02-02T13:01:05.698285Z"
560
+ },
561
+ "papermill": {
562
+ "duration": 0.021202,
563
+ "end_time": "2026-02-02T13:01:05.699979",
564
+ "exception": false,
565
+ "start_time": "2026-02-02T13:01:05.678777",
566
+ "status": "completed"
567
+ },
568
+ "tags": []
569
+ },
570
+ "outputs": [],
571
+ "source": [
572
+ "if not findings.metadata:\n",
573
+ " findings.metadata = {}\n",
574
+ "findings.metadata[\"temporal_quality\"] = reporter.to_dict()\n",
575
+ "findings.save(FINDINGS_PATH)\n",
576
+ "print(f\"Saved to: {FINDINGS_PATH}\")\n",
577
+ "print(f\"Score: {quality_score:.0f}/100 (Grade {grade})\")\n"
578
+ ]
579
+ },
580
+ {
581
+ "cell_type": "markdown",
582
+ "id": "cell-22",
583
+ "metadata": {
584
+ "papermill": {
585
+ "duration": 0.003113,
586
+ "end_time": "2026-02-02T13:01:05.706587",
587
+ "exception": false,
588
+ "start_time": "2026-02-02T13:01:05.703474",
589
+ "status": "completed"
590
+ },
591
+ "tags": []
592
+ },
593
+ "source": [
594
+ "---\n",
595
+ "\n",
596
+ "## Summary: What We Learned\n",
597
+ "\n",
598
+ "In this notebook, we validated temporal data quality:\n",
599
+ "\n",
600
+ "1. **Temporal Quality Checks** — Detected duplicates, gaps, future dates, ordering issues\n",
601
+ "2. **Quality Score** — Quantified overall data health with pass/fail grading\n",
602
+ "3. **Event Volume** — Visualized data coverage over time\n",
603
+ "4. **Outlier Analysis** — Compared global vs segment-aware detection\n",
604
+ "5. **Data Validation** — Verified binary fields and string consistency\n",
605
+ "\n",
606
+ "## Quality Score Interpretation\n",
607
+ "\n",
608
+ "| Grade | Score | Meaning | Action |\n",
609
+ "|-------|-------|---------|--------|\n",
610
+ "| A | 90-100 | Excellent | Proceed with confidence |\n",
611
+ "| B | 75-89 | Good | Document issues, proceed |\n",
612
+ "| C | 60-74 | Fair | Address issues before aggregation |\n",
613
+ "| D | <60 | Poor | Investigation required |\n",
614
+ "\n",
615
+ "---\n",
616
+ "\n",
617
+ "## Next Steps\n",
618
+ "\n",
619
+ "Continue with the **Event Bronze Track**:\n",
620
+ "\n",
621
+ "1. **01c_temporal_patterns.ipynb** — Detect trends, seasonality, cohort effects\n",
622
+ "2. **01d_event_aggregation.ipynb** — Aggregate events to entity-level features\n",
623
+ "\n",
624
+ "After 01d, continue with **Entity Bronze Track** (02 → 03 → 04) on aggregated data."
625
+ ]
626
+ },
627
+ {
628
+ "cell_type": "markdown",
629
+ "id": "f1ec2c4e",
630
+ "metadata": {
631
+ "papermill": {
632
+ "duration": 0.00297,
633
+ "end_time": "2026-02-02T13:01:05.712602",
634
+ "exception": false,
635
+ "start_time": "2026-02-02T13:01:05.709632",
636
+ "status": "completed"
637
+ },
638
+ "tags": []
639
+ },
640
+ "source": [
641
+ "> **Save Reminder:** Save this notebook (Ctrl+S / Cmd+S) before running the next one.\n",
642
+ "> The next notebook will automatically export this notebook's HTML documentation from the saved file."
643
+ ]
644
+ }
645
+ ],
646
+ "metadata": {
647
+ "kernelspec": {
648
+ "display_name": "Python 3",
649
+ "language": "python",
650
+ "name": "python3"
651
+ },
652
+ "language_info": {
653
+ "codemirror_mode": {
654
+ "name": "ipython",
655
+ "version": 3
656
+ },
657
+ "file_extension": ".py",
658
+ "mimetype": "text/x-python",
659
+ "name": "python",
660
+ "nbconvert_exporter": "python",
661
+ "pygments_lexer": "ipython3",
662
+ "version": "3.12.4"
663
+ },
664
+ "papermill": {
665
+ "default_parameters": {},
666
+ "duration": 16.265903,
667
+ "end_time": "2026-02-02T13:01:08.333031",
668
+ "environment_variables": {},
669
+ "exception": null,
670
+ "input_path": "/Users/Vital/python/CustomerRetention/exploration_notebooks/01b_temporal_quality.ipynb",
671
+ "output_path": "/Users/Vital/python/CustomerRetention/exploration_notebooks/01b_temporal_quality.ipynb",
672
+ "parameters": {},
673
+ "start_time": "2026-02-02T13:00:52.067128",
674
+ "version": "2.6.0"
675
+ }
676
+ },
677
+ "nbformat": 4,
678
+ "nbformat_minor": 5
679
+ }