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.
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/00_start_here.ipynb +647 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01_data_discovery.ipynb +1165 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01a_a_temporal_text_deep_dive.ipynb +961 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01a_temporal_deep_dive.ipynb +1690 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01b_temporal_quality.ipynb +679 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01c_temporal_patterns.ipynb +3305 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/01d_event_aggregation.ipynb +1463 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/02_column_deep_dive.ipynb +1430 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/02a_text_columns_deep_dive.ipynb +854 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/03_quality_assessment.ipynb +1639 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/04_relationship_analysis.ipynb +1890 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/05_multi_dataset.ipynb +1457 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/06_feature_opportunities.ipynb +1624 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/07_modeling_readiness.ipynb +780 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/08_baseline_experiments.ipynb +979 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/09_business_alignment.ipynb +572 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/10_spec_generation.ipynb +1179 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/11_scoring_validation.ipynb +1418 -0
- churnkit-0.75.0a1.data/data/share/churnkit/exploration_notebooks/12_view_documentation.ipynb +151 -0
- churnkit-0.75.0a1.dist-info/METADATA +229 -0
- churnkit-0.75.0a1.dist-info/RECORD +302 -0
- churnkit-0.75.0a1.dist-info/WHEEL +4 -0
- churnkit-0.75.0a1.dist-info/entry_points.txt +2 -0
- churnkit-0.75.0a1.dist-info/licenses/LICENSE +202 -0
- customer_retention/__init__.py +37 -0
- customer_retention/analysis/__init__.py +0 -0
- customer_retention/analysis/auto_explorer/__init__.py +62 -0
- customer_retention/analysis/auto_explorer/exploration_manager.py +470 -0
- customer_retention/analysis/auto_explorer/explorer.py +258 -0
- customer_retention/analysis/auto_explorer/findings.py +291 -0
- customer_retention/analysis/auto_explorer/layered_recommendations.py +485 -0
- customer_retention/analysis/auto_explorer/recommendation_builder.py +148 -0
- customer_retention/analysis/auto_explorer/recommendations.py +418 -0
- customer_retention/analysis/business/__init__.py +26 -0
- customer_retention/analysis/business/ab_test_designer.py +144 -0
- customer_retention/analysis/business/fairness_analyzer.py +166 -0
- customer_retention/analysis/business/intervention_matcher.py +121 -0
- customer_retention/analysis/business/report_generator.py +222 -0
- customer_retention/analysis/business/risk_profile.py +199 -0
- customer_retention/analysis/business/roi_analyzer.py +139 -0
- customer_retention/analysis/diagnostics/__init__.py +20 -0
- customer_retention/analysis/diagnostics/calibration_analyzer.py +133 -0
- customer_retention/analysis/diagnostics/cv_analyzer.py +144 -0
- customer_retention/analysis/diagnostics/error_analyzer.py +107 -0
- customer_retention/analysis/diagnostics/leakage_detector.py +394 -0
- customer_retention/analysis/diagnostics/noise_tester.py +140 -0
- customer_retention/analysis/diagnostics/overfitting_analyzer.py +190 -0
- customer_retention/analysis/diagnostics/segment_analyzer.py +122 -0
- customer_retention/analysis/discovery/__init__.py +8 -0
- customer_retention/analysis/discovery/config_generator.py +49 -0
- customer_retention/analysis/discovery/discovery_flow.py +19 -0
- customer_retention/analysis/discovery/type_inferencer.py +147 -0
- customer_retention/analysis/interpretability/__init__.py +13 -0
- customer_retention/analysis/interpretability/cohort_analyzer.py +185 -0
- customer_retention/analysis/interpretability/counterfactual.py +175 -0
- customer_retention/analysis/interpretability/individual_explainer.py +141 -0
- customer_retention/analysis/interpretability/pdp_generator.py +103 -0
- customer_retention/analysis/interpretability/shap_explainer.py +106 -0
- customer_retention/analysis/jupyter_save_hook.py +28 -0
- customer_retention/analysis/notebook_html_exporter.py +136 -0
- customer_retention/analysis/notebook_progress.py +60 -0
- customer_retention/analysis/plotly_preprocessor.py +154 -0
- customer_retention/analysis/recommendations/__init__.py +54 -0
- customer_retention/analysis/recommendations/base.py +158 -0
- customer_retention/analysis/recommendations/cleaning/__init__.py +11 -0
- customer_retention/analysis/recommendations/cleaning/consistency.py +107 -0
- customer_retention/analysis/recommendations/cleaning/deduplicate.py +94 -0
- customer_retention/analysis/recommendations/cleaning/impute.py +67 -0
- customer_retention/analysis/recommendations/cleaning/outlier.py +71 -0
- customer_retention/analysis/recommendations/datetime/__init__.py +3 -0
- customer_retention/analysis/recommendations/datetime/extract.py +149 -0
- customer_retention/analysis/recommendations/encoding/__init__.py +3 -0
- customer_retention/analysis/recommendations/encoding/categorical.py +114 -0
- customer_retention/analysis/recommendations/pipeline.py +74 -0
- customer_retention/analysis/recommendations/registry.py +76 -0
- customer_retention/analysis/recommendations/selection/__init__.py +3 -0
- customer_retention/analysis/recommendations/selection/drop_column.py +56 -0
- customer_retention/analysis/recommendations/transform/__init__.py +4 -0
- customer_retention/analysis/recommendations/transform/power.py +94 -0
- customer_retention/analysis/recommendations/transform/scale.py +112 -0
- customer_retention/analysis/visualization/__init__.py +15 -0
- customer_retention/analysis/visualization/chart_builder.py +2619 -0
- customer_retention/analysis/visualization/console.py +122 -0
- customer_retention/analysis/visualization/display.py +171 -0
- customer_retention/analysis/visualization/number_formatter.py +36 -0
- customer_retention/artifacts/__init__.py +3 -0
- customer_retention/artifacts/fit_artifact_registry.py +146 -0
- customer_retention/cli.py +93 -0
- customer_retention/core/__init__.py +0 -0
- customer_retention/core/compat/__init__.py +193 -0
- customer_retention/core/compat/detection.py +99 -0
- customer_retention/core/compat/ops.py +48 -0
- customer_retention/core/compat/pandas_backend.py +57 -0
- customer_retention/core/compat/spark_backend.py +75 -0
- customer_retention/core/components/__init__.py +11 -0
- customer_retention/core/components/base.py +79 -0
- customer_retention/core/components/components/__init__.py +13 -0
- customer_retention/core/components/components/deployer.py +26 -0
- customer_retention/core/components/components/explainer.py +26 -0
- customer_retention/core/components/components/feature_eng.py +33 -0
- customer_retention/core/components/components/ingester.py +34 -0
- customer_retention/core/components/components/profiler.py +34 -0
- customer_retention/core/components/components/trainer.py +38 -0
- customer_retention/core/components/components/transformer.py +36 -0
- customer_retention/core/components/components/validator.py +37 -0
- customer_retention/core/components/enums.py +33 -0
- customer_retention/core/components/orchestrator.py +94 -0
- customer_retention/core/components/registry.py +59 -0
- customer_retention/core/config/__init__.py +39 -0
- customer_retention/core/config/column_config.py +95 -0
- customer_retention/core/config/experiments.py +71 -0
- customer_retention/core/config/pipeline_config.py +117 -0
- customer_retention/core/config/source_config.py +83 -0
- customer_retention/core/utils/__init__.py +28 -0
- customer_retention/core/utils/leakage.py +85 -0
- customer_retention/core/utils/severity.py +53 -0
- customer_retention/core/utils/statistics.py +90 -0
- customer_retention/generators/__init__.py +0 -0
- customer_retention/generators/notebook_generator/__init__.py +167 -0
- customer_retention/generators/notebook_generator/base.py +55 -0
- customer_retention/generators/notebook_generator/cell_builder.py +49 -0
- customer_retention/generators/notebook_generator/config.py +47 -0
- customer_retention/generators/notebook_generator/databricks_generator.py +48 -0
- customer_retention/generators/notebook_generator/local_generator.py +48 -0
- customer_retention/generators/notebook_generator/project_init.py +174 -0
- customer_retention/generators/notebook_generator/runner.py +150 -0
- customer_retention/generators/notebook_generator/script_generator.py +110 -0
- customer_retention/generators/notebook_generator/stages/__init__.py +19 -0
- customer_retention/generators/notebook_generator/stages/base_stage.py +86 -0
- customer_retention/generators/notebook_generator/stages/s01_ingestion.py +100 -0
- customer_retention/generators/notebook_generator/stages/s02_profiling.py +95 -0
- customer_retention/generators/notebook_generator/stages/s03_cleaning.py +180 -0
- customer_retention/generators/notebook_generator/stages/s04_transformation.py +165 -0
- customer_retention/generators/notebook_generator/stages/s05_feature_engineering.py +115 -0
- customer_retention/generators/notebook_generator/stages/s06_feature_selection.py +97 -0
- customer_retention/generators/notebook_generator/stages/s07_model_training.py +176 -0
- customer_retention/generators/notebook_generator/stages/s08_deployment.py +81 -0
- customer_retention/generators/notebook_generator/stages/s09_monitoring.py +112 -0
- customer_retention/generators/notebook_generator/stages/s10_batch_inference.py +642 -0
- customer_retention/generators/notebook_generator/stages/s11_feature_store.py +348 -0
- customer_retention/generators/orchestration/__init__.py +23 -0
- customer_retention/generators/orchestration/code_generator.py +196 -0
- customer_retention/generators/orchestration/context.py +147 -0
- customer_retention/generators/orchestration/data_materializer.py +188 -0
- customer_retention/generators/orchestration/databricks_exporter.py +411 -0
- customer_retention/generators/orchestration/doc_generator.py +311 -0
- customer_retention/generators/pipeline_generator/__init__.py +26 -0
- customer_retention/generators/pipeline_generator/findings_parser.py +727 -0
- customer_retention/generators/pipeline_generator/generator.py +142 -0
- customer_retention/generators/pipeline_generator/models.py +166 -0
- customer_retention/generators/pipeline_generator/renderer.py +2125 -0
- customer_retention/generators/spec_generator/__init__.py +37 -0
- customer_retention/generators/spec_generator/databricks_generator.py +433 -0
- customer_retention/generators/spec_generator/generic_generator.py +373 -0
- customer_retention/generators/spec_generator/mlflow_pipeline_generator.py +685 -0
- customer_retention/generators/spec_generator/pipeline_spec.py +298 -0
- customer_retention/integrations/__init__.py +0 -0
- customer_retention/integrations/adapters/__init__.py +13 -0
- customer_retention/integrations/adapters/base.py +10 -0
- customer_retention/integrations/adapters/factory.py +25 -0
- customer_retention/integrations/adapters/feature_store/__init__.py +6 -0
- customer_retention/integrations/adapters/feature_store/base.py +57 -0
- customer_retention/integrations/adapters/feature_store/databricks.py +94 -0
- customer_retention/integrations/adapters/feature_store/feast_adapter.py +97 -0
- customer_retention/integrations/adapters/feature_store/local.py +75 -0
- customer_retention/integrations/adapters/mlflow/__init__.py +6 -0
- customer_retention/integrations/adapters/mlflow/base.py +32 -0
- customer_retention/integrations/adapters/mlflow/databricks.py +54 -0
- customer_retention/integrations/adapters/mlflow/experiment_tracker.py +161 -0
- customer_retention/integrations/adapters/mlflow/local.py +50 -0
- customer_retention/integrations/adapters/storage/__init__.py +5 -0
- customer_retention/integrations/adapters/storage/base.py +33 -0
- customer_retention/integrations/adapters/storage/databricks.py +76 -0
- customer_retention/integrations/adapters/storage/local.py +59 -0
- customer_retention/integrations/feature_store/__init__.py +47 -0
- customer_retention/integrations/feature_store/definitions.py +215 -0
- customer_retention/integrations/feature_store/manager.py +744 -0
- customer_retention/integrations/feature_store/registry.py +412 -0
- customer_retention/integrations/iteration/__init__.py +28 -0
- customer_retention/integrations/iteration/context.py +212 -0
- customer_retention/integrations/iteration/feedback_collector.py +184 -0
- customer_retention/integrations/iteration/orchestrator.py +168 -0
- customer_retention/integrations/iteration/recommendation_tracker.py +341 -0
- customer_retention/integrations/iteration/signals.py +212 -0
- customer_retention/integrations/llm_context/__init__.py +4 -0
- customer_retention/integrations/llm_context/context_builder.py +201 -0
- customer_retention/integrations/llm_context/prompts.py +100 -0
- customer_retention/integrations/streaming/__init__.py +103 -0
- customer_retention/integrations/streaming/batch_integration.py +149 -0
- customer_retention/integrations/streaming/early_warning_model.py +227 -0
- customer_retention/integrations/streaming/event_schema.py +214 -0
- customer_retention/integrations/streaming/online_store_writer.py +249 -0
- customer_retention/integrations/streaming/realtime_scorer.py +261 -0
- customer_retention/integrations/streaming/trigger_engine.py +293 -0
- customer_retention/integrations/streaming/window_aggregator.py +393 -0
- customer_retention/stages/__init__.py +0 -0
- customer_retention/stages/cleaning/__init__.py +9 -0
- customer_retention/stages/cleaning/base.py +28 -0
- customer_retention/stages/cleaning/missing_handler.py +160 -0
- customer_retention/stages/cleaning/outlier_handler.py +204 -0
- customer_retention/stages/deployment/__init__.py +28 -0
- customer_retention/stages/deployment/batch_scorer.py +106 -0
- customer_retention/stages/deployment/champion_challenger.py +299 -0
- customer_retention/stages/deployment/model_registry.py +182 -0
- customer_retention/stages/deployment/retraining_trigger.py +245 -0
- customer_retention/stages/features/__init__.py +73 -0
- customer_retention/stages/features/behavioral_features.py +266 -0
- customer_retention/stages/features/customer_segmentation.py +505 -0
- customer_retention/stages/features/feature_definitions.py +265 -0
- customer_retention/stages/features/feature_engineer.py +551 -0
- customer_retention/stages/features/feature_manifest.py +340 -0
- customer_retention/stages/features/feature_selector.py +239 -0
- customer_retention/stages/features/interaction_features.py +160 -0
- customer_retention/stages/features/temporal_features.py +243 -0
- customer_retention/stages/ingestion/__init__.py +9 -0
- customer_retention/stages/ingestion/load_result.py +32 -0
- customer_retention/stages/ingestion/loaders.py +195 -0
- customer_retention/stages/ingestion/source_registry.py +130 -0
- customer_retention/stages/modeling/__init__.py +31 -0
- customer_retention/stages/modeling/baseline_trainer.py +139 -0
- customer_retention/stages/modeling/cross_validator.py +125 -0
- customer_retention/stages/modeling/data_splitter.py +205 -0
- customer_retention/stages/modeling/feature_scaler.py +99 -0
- customer_retention/stages/modeling/hyperparameter_tuner.py +107 -0
- customer_retention/stages/modeling/imbalance_handler.py +282 -0
- customer_retention/stages/modeling/mlflow_logger.py +95 -0
- customer_retention/stages/modeling/model_comparator.py +149 -0
- customer_retention/stages/modeling/model_evaluator.py +138 -0
- customer_retention/stages/modeling/threshold_optimizer.py +131 -0
- customer_retention/stages/monitoring/__init__.py +37 -0
- customer_retention/stages/monitoring/alert_manager.py +328 -0
- customer_retention/stages/monitoring/drift_detector.py +201 -0
- customer_retention/stages/monitoring/performance_monitor.py +242 -0
- customer_retention/stages/preprocessing/__init__.py +5 -0
- customer_retention/stages/preprocessing/transformer_manager.py +284 -0
- customer_retention/stages/profiling/__init__.py +256 -0
- customer_retention/stages/profiling/categorical_distribution.py +269 -0
- customer_retention/stages/profiling/categorical_target_analyzer.py +274 -0
- customer_retention/stages/profiling/column_profiler.py +527 -0
- customer_retention/stages/profiling/distribution_analysis.py +483 -0
- customer_retention/stages/profiling/drift_detector.py +310 -0
- customer_retention/stages/profiling/feature_capacity.py +507 -0
- customer_retention/stages/profiling/pattern_analysis_config.py +513 -0
- customer_retention/stages/profiling/profile_result.py +212 -0
- customer_retention/stages/profiling/quality_checks.py +1632 -0
- customer_retention/stages/profiling/relationship_detector.py +256 -0
- customer_retention/stages/profiling/relationship_recommender.py +454 -0
- customer_retention/stages/profiling/report_generator.py +520 -0
- customer_retention/stages/profiling/scd_analyzer.py +151 -0
- customer_retention/stages/profiling/segment_analyzer.py +632 -0
- customer_retention/stages/profiling/segment_aware_outlier.py +265 -0
- customer_retention/stages/profiling/target_level_analyzer.py +217 -0
- customer_retention/stages/profiling/temporal_analyzer.py +388 -0
- customer_retention/stages/profiling/temporal_coverage.py +488 -0
- customer_retention/stages/profiling/temporal_feature_analyzer.py +692 -0
- customer_retention/stages/profiling/temporal_feature_engineer.py +703 -0
- customer_retention/stages/profiling/temporal_pattern_analyzer.py +636 -0
- customer_retention/stages/profiling/temporal_quality_checks.py +278 -0
- customer_retention/stages/profiling/temporal_target_analyzer.py +241 -0
- customer_retention/stages/profiling/text_embedder.py +87 -0
- customer_retention/stages/profiling/text_processor.py +115 -0
- customer_retention/stages/profiling/text_reducer.py +60 -0
- customer_retention/stages/profiling/time_series_profiler.py +303 -0
- customer_retention/stages/profiling/time_window_aggregator.py +376 -0
- customer_retention/stages/profiling/type_detector.py +382 -0
- customer_retention/stages/profiling/window_recommendation.py +288 -0
- customer_retention/stages/temporal/__init__.py +166 -0
- customer_retention/stages/temporal/access_guard.py +180 -0
- customer_retention/stages/temporal/cutoff_analyzer.py +235 -0
- customer_retention/stages/temporal/data_preparer.py +178 -0
- customer_retention/stages/temporal/point_in_time_join.py +134 -0
- customer_retention/stages/temporal/point_in_time_registry.py +148 -0
- customer_retention/stages/temporal/scenario_detector.py +163 -0
- customer_retention/stages/temporal/snapshot_manager.py +259 -0
- customer_retention/stages/temporal/synthetic_coordinator.py +66 -0
- customer_retention/stages/temporal/timestamp_discovery.py +531 -0
- customer_retention/stages/temporal/timestamp_manager.py +255 -0
- customer_retention/stages/transformation/__init__.py +13 -0
- customer_retention/stages/transformation/binary_handler.py +85 -0
- customer_retention/stages/transformation/categorical_encoder.py +245 -0
- customer_retention/stages/transformation/datetime_transformer.py +97 -0
- customer_retention/stages/transformation/numeric_transformer.py +181 -0
- customer_retention/stages/transformation/pipeline.py +257 -0
- customer_retention/stages/validation/__init__.py +60 -0
- customer_retention/stages/validation/adversarial_scoring_validator.py +205 -0
- customer_retention/stages/validation/business_sense_gate.py +173 -0
- customer_retention/stages/validation/data_quality_gate.py +235 -0
- customer_retention/stages/validation/data_validators.py +511 -0
- customer_retention/stages/validation/feature_quality_gate.py +183 -0
- customer_retention/stages/validation/gates.py +117 -0
- customer_retention/stages/validation/leakage_gate.py +352 -0
- customer_retention/stages/validation/model_validity_gate.py +213 -0
- customer_retention/stages/validation/pipeline_validation_runner.py +264 -0
- customer_retention/stages/validation/quality_scorer.py +544 -0
- customer_retention/stages/validation/rule_generator.py +57 -0
- customer_retention/stages/validation/scoring_pipeline_validator.py +446 -0
- customer_retention/stages/validation/timeseries_detector.py +769 -0
- customer_retention/transforms/__init__.py +47 -0
- customer_retention/transforms/artifact_store.py +50 -0
- customer_retention/transforms/executor.py +157 -0
- customer_retention/transforms/fitted.py +92 -0
- customer_retention/transforms/ops.py +148 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from .findings_parser import FindingsParser
|
|
5
|
+
from .models import PipelineConfig
|
|
6
|
+
from .renderer import CodeRenderer
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PipelineGenerator:
|
|
10
|
+
def __init__(self, findings_dir: str, output_dir: str, pipeline_name: str, experiments_dir: str = None, production_dir: str = None):
|
|
11
|
+
self._findings_dir = Path(findings_dir)
|
|
12
|
+
self._output_dir = Path(output_dir)
|
|
13
|
+
self._pipeline_name = pipeline_name
|
|
14
|
+
self._experiments_dir = experiments_dir
|
|
15
|
+
self._production_dir = production_dir
|
|
16
|
+
self._parser = FindingsParser(findings_dir)
|
|
17
|
+
self._renderer = CodeRenderer()
|
|
18
|
+
|
|
19
|
+
def generate(self) -> List[Path]:
|
|
20
|
+
config = self._parser.parse()
|
|
21
|
+
config.name = self._pipeline_name
|
|
22
|
+
config.output_dir = "."
|
|
23
|
+
config.experiments_dir = self._experiments_dir
|
|
24
|
+
config.production_dir = self._production_dir
|
|
25
|
+
self._renderer.set_docs_base(self._experiments_dir)
|
|
26
|
+
generated_files = [
|
|
27
|
+
self._write_run_all(config),
|
|
28
|
+
self._write_config(config),
|
|
29
|
+
*self._write_landing(config),
|
|
30
|
+
*self._write_bronze_files(config),
|
|
31
|
+
self._write_silver(config),
|
|
32
|
+
self._write_gold(config),
|
|
33
|
+
self._write_training(config),
|
|
34
|
+
self._write_runner(config),
|
|
35
|
+
self._write_workflow(config),
|
|
36
|
+
*self._write_feast_repo(config),
|
|
37
|
+
*self._write_validation(config),
|
|
38
|
+
self._write_exploration_report(config),
|
|
39
|
+
]
|
|
40
|
+
return generated_files
|
|
41
|
+
|
|
42
|
+
def _write_run_all(self, config: PipelineConfig) -> Path:
|
|
43
|
+
path = self._output_dir / "run_all.py"
|
|
44
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
45
|
+
path.write_text(self._renderer.render_run_all(config))
|
|
46
|
+
return path
|
|
47
|
+
|
|
48
|
+
def _write_config(self, config: PipelineConfig) -> Path:
|
|
49
|
+
path = self._output_dir / "config.py"
|
|
50
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
51
|
+
path.write_text(self._renderer.render_config(config))
|
|
52
|
+
return path
|
|
53
|
+
|
|
54
|
+
def _write_landing(self, config: PipelineConfig) -> List[Path]:
|
|
55
|
+
if not config.landing:
|
|
56
|
+
return []
|
|
57
|
+
landing_dir = self._output_dir / "landing"
|
|
58
|
+
landing_dir.mkdir(parents=True, exist_ok=True)
|
|
59
|
+
paths = []
|
|
60
|
+
for landing_name, landing_config in config.landing.items():
|
|
61
|
+
path = landing_dir / f"landing_{landing_name}.py"
|
|
62
|
+
path.write_text(self._renderer.render_landing(landing_name, landing_config))
|
|
63
|
+
paths.append(path)
|
|
64
|
+
return paths
|
|
65
|
+
|
|
66
|
+
def _write_bronze_files(self, config: PipelineConfig) -> List[Path]:
|
|
67
|
+
bronze_dir = self._output_dir / "bronze"
|
|
68
|
+
bronze_dir.mkdir(parents=True, exist_ok=True)
|
|
69
|
+
paths = []
|
|
70
|
+
for source_name, bronze_config in config.bronze.items():
|
|
71
|
+
path = bronze_dir / f"bronze_{source_name}.py"
|
|
72
|
+
path.write_text(self._renderer.render_bronze(source_name, bronze_config))
|
|
73
|
+
paths.append(path)
|
|
74
|
+
for source_name, event_config in config.bronze_event.items():
|
|
75
|
+
path = bronze_dir / f"bronze_{source_name}.py"
|
|
76
|
+
path.write_text(self._renderer.render_bronze_event(source_name, event_config))
|
|
77
|
+
paths.append(path)
|
|
78
|
+
return paths
|
|
79
|
+
|
|
80
|
+
def _write_silver(self, config: PipelineConfig) -> Path:
|
|
81
|
+
path = self._output_dir / "silver" / "silver_merge.py"
|
|
82
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
83
|
+
path.write_text(self._renderer.render_silver(config))
|
|
84
|
+
return path
|
|
85
|
+
|
|
86
|
+
def _write_gold(self, config: PipelineConfig) -> Path:
|
|
87
|
+
path = self._output_dir / "gold" / "gold_features.py"
|
|
88
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
89
|
+
path.write_text(self._renderer.render_gold(config))
|
|
90
|
+
return path
|
|
91
|
+
|
|
92
|
+
def _write_training(self, config: PipelineConfig) -> Path:
|
|
93
|
+
path = self._output_dir / "training" / "ml_experiment.py"
|
|
94
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
95
|
+
path.write_text(self._renderer.render_training(config))
|
|
96
|
+
return path
|
|
97
|
+
|
|
98
|
+
def _write_runner(self, config: PipelineConfig) -> Path:
|
|
99
|
+
path = self._output_dir / "pipeline_runner.py"
|
|
100
|
+
path.write_text(self._renderer.render_runner(config))
|
|
101
|
+
return path
|
|
102
|
+
|
|
103
|
+
def _write_workflow(self, config: PipelineConfig) -> Path:
|
|
104
|
+
path = self._output_dir / "workflow.json"
|
|
105
|
+
path.write_text(self._renderer.render_workflow(config))
|
|
106
|
+
return path
|
|
107
|
+
|
|
108
|
+
def _write_feast_repo(self, config: PipelineConfig) -> List[Path]:
|
|
109
|
+
feast_dir = self._output_dir / "feature_repo"
|
|
110
|
+
feast_dir.mkdir(parents=True, exist_ok=True)
|
|
111
|
+
(feast_dir / "data").mkdir(parents=True, exist_ok=True)
|
|
112
|
+
paths = []
|
|
113
|
+
config_path = feast_dir / "feature_store.yaml"
|
|
114
|
+
config_path.write_text(self._renderer.render_feast_config(config))
|
|
115
|
+
paths.append(config_path)
|
|
116
|
+
features_path = feast_dir / "features.py"
|
|
117
|
+
features_path.write_text(self._renderer.render_feast_features(config))
|
|
118
|
+
paths.append(features_path)
|
|
119
|
+
return paths
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _write_exploration_report(self, config: PipelineConfig) -> Path:
|
|
123
|
+
docs_dir = self._output_dir / "docs"
|
|
124
|
+
docs_dir.mkdir(parents=True, exist_ok=True)
|
|
125
|
+
path = docs_dir / "exploration_report.py"
|
|
126
|
+
path.write_text(self._renderer.render_exploration_report(config))
|
|
127
|
+
return path
|
|
128
|
+
|
|
129
|
+
def _write_validation(self, config: PipelineConfig) -> List[Path]:
|
|
130
|
+
validation_dir = self._output_dir / "validation"
|
|
131
|
+
validation_dir.mkdir(parents=True, exist_ok=True)
|
|
132
|
+
paths = []
|
|
133
|
+
init_path = validation_dir / "__init__.py"
|
|
134
|
+
init_path.write_text("")
|
|
135
|
+
paths.append(init_path)
|
|
136
|
+
validate_path = validation_dir / "validate_pipeline.py"
|
|
137
|
+
validate_path.write_text(self._renderer.render_validation(config))
|
|
138
|
+
paths.append(validate_path)
|
|
139
|
+
run_validation_path = validation_dir / "run_validation.py"
|
|
140
|
+
run_validation_path.write_text(self._renderer.render_run_validation(config))
|
|
141
|
+
paths.append(run_validation_path)
|
|
142
|
+
return paths
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PipelineTransformationType(Enum):
|
|
7
|
+
IMPUTE_NULL = "impute_null"
|
|
8
|
+
CAP_OUTLIER = "cap_outlier"
|
|
9
|
+
TYPE_CAST = "type_cast"
|
|
10
|
+
ENCODE = "encode"
|
|
11
|
+
SCALE = "scale"
|
|
12
|
+
AGGREGATE = "aggregate"
|
|
13
|
+
JOIN = "join"
|
|
14
|
+
DROP_COLUMN = "drop_column"
|
|
15
|
+
WINSORIZE = "winsorize"
|
|
16
|
+
SEGMENT_AWARE_CAP = "segment_aware_cap"
|
|
17
|
+
LOG_TRANSFORM = "log_transform"
|
|
18
|
+
SQRT_TRANSFORM = "sqrt_transform"
|
|
19
|
+
YEO_JOHNSON = "yeo_johnson"
|
|
20
|
+
ZERO_INFLATION_HANDLING = "zero_inflation_handling"
|
|
21
|
+
CAP_THEN_LOG = "cap_then_log"
|
|
22
|
+
FEATURE_SELECT = "feature_select"
|
|
23
|
+
DERIVED_COLUMN = "derived_column"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class SourceConfig:
|
|
28
|
+
name: str
|
|
29
|
+
path: str
|
|
30
|
+
format: str
|
|
31
|
+
entity_key: str
|
|
32
|
+
raw_source_path: str = ""
|
|
33
|
+
time_column: Optional[str] = None
|
|
34
|
+
is_event_level: bool = False
|
|
35
|
+
excluded: bool = False
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass
|
|
39
|
+
class TransformationStep:
|
|
40
|
+
type: PipelineTransformationType
|
|
41
|
+
column: str
|
|
42
|
+
parameters: Dict[str, Any]
|
|
43
|
+
rationale: str
|
|
44
|
+
source_notebook: Optional[str] = None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass
|
|
48
|
+
class BronzeLayerConfig:
|
|
49
|
+
source: SourceConfig
|
|
50
|
+
transformations: List[TransformationStep] = field(default_factory=list)
|
|
51
|
+
lifecycle: Optional["LifecycleConfig"] = None
|
|
52
|
+
entity_column: Optional[str] = None
|
|
53
|
+
time_column: Optional[str] = None
|
|
54
|
+
raw_time_column: Optional[str] = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass
|
|
58
|
+
class SilverLayerConfig:
|
|
59
|
+
joins: List[Dict[str, str]] = field(default_factory=list)
|
|
60
|
+
aggregations: List[Dict[str, Any]] = field(default_factory=list)
|
|
61
|
+
derived_columns: List[TransformationStep] = field(default_factory=list)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass
|
|
65
|
+
class GoldLayerConfig:
|
|
66
|
+
encodings: List[TransformationStep] = field(default_factory=list)
|
|
67
|
+
scalings: List[TransformationStep] = field(default_factory=list)
|
|
68
|
+
feature_selections: List[str] = field(default_factory=list)
|
|
69
|
+
transformations: List[TransformationStep] = field(default_factory=list)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass
|
|
73
|
+
class FeastConfig:
|
|
74
|
+
repo_path: str = "./feature_repo"
|
|
75
|
+
feature_view_name: str = "customer_features"
|
|
76
|
+
entity_name: str = "customer"
|
|
77
|
+
entity_key: str = "customer_id"
|
|
78
|
+
timestamp_column: str = "event_timestamp"
|
|
79
|
+
ttl_days: int = 365
|
|
80
|
+
exclude_prefixes: List[str] = field(default_factory=lambda: ["original_"])
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class ScoringConfig:
|
|
85
|
+
holdout_manifest_path: Optional[str] = None
|
|
86
|
+
original_column: Optional[str] = None
|
|
87
|
+
model_uri: Optional[str] = None
|
|
88
|
+
output_predictions_path: Optional[str] = None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@dataclass
|
|
92
|
+
class AggregationWindowConfig:
|
|
93
|
+
windows: List[str] = field(default_factory=list)
|
|
94
|
+
value_columns: List[str] = field(default_factory=list)
|
|
95
|
+
agg_funcs: List[str] = field(default_factory=list)
|
|
96
|
+
reference_date: Optional[str] = None
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@dataclass
|
|
100
|
+
class LifecycleConfig:
|
|
101
|
+
include_lifecycle_quadrant: bool = False
|
|
102
|
+
include_cyclical_features: bool = False
|
|
103
|
+
include_recency_bucket: bool = False
|
|
104
|
+
momentum_pairs: List[Dict[str, Any]] = field(default_factory=list)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@dataclass
|
|
108
|
+
class TimestampCoalesceConfig:
|
|
109
|
+
datetime_columns_ordered: List[str]
|
|
110
|
+
output_column: str = "feature_timestamp"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass
|
|
114
|
+
class LabelTimestampConfig:
|
|
115
|
+
label_column: Optional[str] = None
|
|
116
|
+
fallback_window_days: int = 180
|
|
117
|
+
output_column: str = "label_timestamp"
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@dataclass
|
|
121
|
+
class BronzeEventConfig:
|
|
122
|
+
source: SourceConfig
|
|
123
|
+
entity_column: str
|
|
124
|
+
time_column: str
|
|
125
|
+
deduplicate: bool = False
|
|
126
|
+
pre_shaping: List[TransformationStep] = field(default_factory=list)
|
|
127
|
+
aggregation: Optional[AggregationWindowConfig] = None
|
|
128
|
+
lifecycle: Optional[LifecycleConfig] = None
|
|
129
|
+
post_shaping: List[TransformationStep] = field(default_factory=list)
|
|
130
|
+
raw_time_column: Optional[str] = None
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@dataclass
|
|
134
|
+
class LandingLayerConfig:
|
|
135
|
+
source: SourceConfig
|
|
136
|
+
raw_source_path: str
|
|
137
|
+
raw_source_format: str
|
|
138
|
+
entity_column: str
|
|
139
|
+
time_column: str
|
|
140
|
+
target_column: str
|
|
141
|
+
original_target_column: Optional[str] = None
|
|
142
|
+
raw_time_column: Optional[str] = None
|
|
143
|
+
timestamp_coalesce: Optional[TimestampCoalesceConfig] = None
|
|
144
|
+
label_timestamp: Optional[LabelTimestampConfig] = None
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@dataclass
|
|
148
|
+
class PipelineConfig:
|
|
149
|
+
name: str
|
|
150
|
+
target_column: str
|
|
151
|
+
sources: List[SourceConfig]
|
|
152
|
+
bronze: Dict[str, BronzeLayerConfig]
|
|
153
|
+
silver: SilverLayerConfig
|
|
154
|
+
gold: GoldLayerConfig
|
|
155
|
+
output_dir: str
|
|
156
|
+
iteration_id: Optional[str] = None
|
|
157
|
+
parent_iteration_id: Optional[str] = None
|
|
158
|
+
recommendations_hash: Optional[str] = None
|
|
159
|
+
feast: Optional[FeastConfig] = None
|
|
160
|
+
scoring: Optional[ScoringConfig] = None
|
|
161
|
+
experiments_dir: Optional[str] = None
|
|
162
|
+
production_dir: Optional[str] = None
|
|
163
|
+
fit_mode: bool = True
|
|
164
|
+
artifacts_path: Optional[str] = None
|
|
165
|
+
landing: Dict[str, LandingLayerConfig] = field(default_factory=dict)
|
|
166
|
+
bronze_event: Dict[str, BronzeEventConfig] = field(default_factory=dict)
|