Pipelines¶
churn_prediction.pipelines.training_pipeline
¶
Training Pipeline for Churn Prediction.
This module provides a CLI interface to orchestrate the training pipeline, including ingestion, schema validation, preprocessing of training and validation datasets and training the xgboost model. It is designed to be integrated with DVC (Data Version Control) for pipeline reproducibility.
run_all_stages(settings)
¶
Execute the complete training pipeline.
Runs ingestion, raw-data validation, preprocessing, processed-data validation, and model training sequentially using the supplied application settings.
Source code in src/churn_prediction/pipelines/training_pipeline.py
155 156 157 158 159 160 161 162 163 164 165 166 167 | |
run_ingestion(settings)
¶
Execute the dataset ingestion stage.
Downloads or retrieves the configured raw dataset and prepares the expected local dataset artifacts.
Source code in src/churn_prediction/pipelines/training_pipeline.py
21 22 23 24 25 26 27 28 29 30 31 | |
run_preprocessing(settings)
¶
Execute the training preprocessing stage.
Transforms the raw dataset into model-ready training and validation datasets and persists the fitted preprocessing artifact.
Source code in src/churn_prediction/pipelines/training_pipeline.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
run_raw_validation(settings)
¶
Execute raw dataset validation.
Validates the ingested raw dataset against RAW_SCHEMA and writes
validation diagnostics to the configured report location.
Source code in src/churn_prediction/pipelines/training_pipeline.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
run_train_validation(settings)
¶
Validate the processed training dataset.
Checks the generated training dataset against PROCESSED_SCHEMA and
records any validation failures in the configured validation report.
Source code in src/churn_prediction/pipelines/training_pipeline.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
run_training(settings)
¶
Execute the model training stage.
Trains the configured XGBoost model using the processed training and validation datasets and exports the resulting model, model card, and training report.
Source code in src/churn_prediction/pipelines/training_pipeline.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
run_val_validation(settings)
¶
Validate the processed validation dataset.
Checks the generated validation dataset against PROCESSED_SCHEMA
and records any validation failures in the configured validation report.
Source code in src/churn_prediction/pipelines/training_pipeline.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
churn_prediction.pipelines.prediction_pipeline
¶
Prediction Pipeline for Churn Prediction.
This module defines the end-to-end workflow for generating predictions on new data, integrating dataset validation, feature preprocessing, and model inference.
run_prediction_pipeline(batch_id, raw_file_path, loaded_encoder, loaded_booster)
¶
Execute the complete batch prediction workflow.
The pipeline validates the raw input dataset, transforms it using the pre-fitted encoder, validates the resulting model-ready dataset, and generates predictions using the trained XGBoost booster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_id
|
str
|
Unique identifier for the current prediction batch. |
required |
raw_file_path
|
str or Path
|
Path to the raw customer dataset to be scored. |
required |
loaded_encoder
|
OrdinalEncoder
|
Pre-fitted encoder used to transform categorical features. |
required |
loaded_booster
|
Booster
|
Trained XGBoost model used to generate churn predictions. |
required |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the input dataset or required output directories are unavailable. |
ValueError
|
If raw or processed data fails validation or preprocessing fails. |
RuntimeError
|
If model inference or artifact persistence fails. |
Source code in src/churn_prediction/pipelines/prediction_pipeline.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |