Analysis overview and configuration
| Parameter | Value | _row |
|---|---|---|
| n_rounds | 150 | n_rounds |
| max_depth | 6 | max_depth |
| learning_rate | 0.1 | learning_rate |
| subsample | 0.8 | subsample |
| colsample_bytree | 0.8 | colsample_bytree |
| early_stopping | 20 | early_stopping |
| threshold | 0.5 | threshold |
| test_size | 0.2 | test_size |
| n_top_countries | 8 | n_top_countries |
This XGBoost analysis predicts high-value retail transactions using 13 features across 48,548 observations. The model incorporates SHAP explainability to understand feature contributions, enabling both predictive accuracy and interpretability for business decision-making.
qty_capped (gain=0.6, SHAP=5.45) and log_unit_price (gain=0.38, SHAP=3.32) drive 98% of model decisions; remaining 11 features contribute negligibly.The model achieves exceptional predictive power by isolating two transaction-level attributes—quantity and unit price—as primary value indicators. Geographic and temporal features (country, hour
Data preprocessing and column mapping
| Metric | Value |
|---|---|
| Initial Rows | 50,000 |
| Final Rows | 48,548 |
| Rows Removed | 1,452 |
| Retention Rate | 97.1% |
This section documents the data cleaning and preparation phase that precedes the XGBoost classification model. Understanding preprocessing quality is critical because data loss and transformation decisions directly impact model training stability, generalization performance, and the reliability of business conclusions drawn from the analysis.
The preprocessing retained nearly all observations, which supports the model's ability to achieve perfect classification metrics (AUC-ROC = 1.0, Accuracy = 1.0). The 1,452 removed rows likely contained missing values, outliers, or invalid entries that could have introduced noise. This conservative cleaning approach preserved statistical power while maintaining data integrity, enabling the model to learn robust patterns from the 13 features without excessive information loss.
The train-test split details are not explicitly documented in the preprocessing section, though the overall metrics confirm an 80/20 allocation. The high retention rate combined with perfect model performance
| finding | value |
|---|---|
| Model Performance | AUC=1.000 (excellent) |
| Top Predictive Feature | qty_capped |
| Classification Threshold | 0.5 (Accuracy: 100.0%) |
| Training Convergence | Best round: 150 |
| Class Balance | 49.8% high-value transactions |
| Generalization | Model generalizes well (train AUC: 1, test AUC: 1). |
This section synthesizes the XGBoost classification model's performance on transaction value prediction. The analysis evaluates whether the model successfully identifies high-value transactions and is ready for operational deployment, directly supporting revenue optimization and customer targeting objectives.
qty_capped (gain=0.60, SHAP=5.45) and log_unit_price (gain=0.38, SHAP=3.32) drive 98% of predictive powerThe model achieves exceptional predictive performance with perfect separation of transaction classes. The near-zero false negative rate (0 missed high-value transactions) and minimal false positive rate (2
XGBoost feature importance by normalized Gain
This section identifies which features contribute most to the model's decision-making through gain-based importance. Gain measures the information value each feature provides when splitting data in the boosting trees. Understanding feature importance reveals which transaction attributes are most predictive of high-value versus low-value classifications.
The model relies almost exclusively on quantity and unit price to classify transactions. The extreme concentration in qty_capped (60.3%) indicates this single feature carries the majority of predictive power. The near-zero contributions from geographic and temporal features suggest the transaction value classification is fundamentally driven by product-level characteristics rather than when or where transactions occur. This aligns with the model's perfect performance (AUC
SHAP (Shapley) feature importance — model-agnostic explanation
SHAP values provide model-agnostic explanations of how individual features drive predictions, accounting for feature correlations. This section reveals which variables most strongly influence the XGBoost classifier's decisions to classify transactions as high-value or low-value, complementing tree-based gain metrics with a theoretically sound attribution method.
The model's perfect performance (AUC=1.0, Accuracy=1.0) is driven almost entirely by transaction quantity and unit price. These features create a clear separation between high-value and low-value transactions, while temporal and geographic dimensions provide negligible marginal contribution. This aligns with the balanced
Training vs test log-loss by boosting round
This section tracks model performance improvement across 150 boosting iterations, showing how log-loss decreases as the XGBoost ensemble adds sequential trees. Learning curves validate that the model generalizes well by comparing training and test performance, ensuring the model hasn't overfit despite achieving perfect classification metrics.
The model exhibits exceptional learning dynamics: initial log-loss of ~0.65 on training data drops rapidly within the first few iterations, stabilizing near zero by round 150. The parallel trajectory of train and test curves suggests the model learned generalizable patterns rather than memorizing training data. Perfect AUC scores on both sets indicate the classifier achieves flawless separation of high-value and low-value transactions.
These results assume the test set is representative of production data and that the 48,548 samples retained after preprocessing are sufficient for reliable curve estimation
ROC curve — AUC = 1.000
This section evaluates the XGBoost model's ability to discriminate between high-value and low-value transactions across all classification thresholds. The ROC curve and AUC metric directly measure classification performance, which is central to assessing whether the model reliably identifies transaction patterns for business decision-making.
The model achieves exceptional performance with zero classification error on the test set. The ROC curve reaches the top-left corner (TPR=1, FPR≈0), indicating the model separates classes nearly perfectly at optimal thresholds. The alignment between train and test AUC suggests the model generalizes well without overfitting, despite using 13 features with only 2 dominant predictors
Confusion matrix — classification results at chosen threshold
The confusion matrix quantifies classification performance at the 0.5 decision threshold, showing how well the XGBoost model distinguishes between high-value and low-value transactions. This section is critical for assessing whether the model's predictive accuracy translates into reliable real-world decision-making for revenue classification.
The model achieves near-perfect classification with only 2 false positives across 9,709 test cases. The zero false negatives mean no revenue-generating transactions are missed, while the minimal false positive rate prevents unnecessary resource allocation to low-value customers. This exceptional performance suggests the model has learned highly discriminative patterns
Complete classification performance metrics
| metric | value |
|---|---|
| AUC-ROC | 1 |
| Accuracy | 1 |
| Precision | 1 |
| Recall | 1 |
| F1 Score | 1 |
| Best Round | 150 |
| Train AUC | 1 |
| Threshold | 0.5 |
| feature | gain | cover | frequency | mean_abs_shap |
|---|---|---|---|---|
| qty_capped | 0.6026 | 0.3928 | 0.3386 | 5.445 |
| log_unit_price | 0.3792 | 0.3676 | 0.3671 | 3.317 |
| hour_of_day | 0.0076 | 0.1245 | 0.1495 | 0.0754 |
| country_United_Kingdom | 0.0062 | 0.0411 | 0.0197 | 0.0536 |
| day_of_week | 0.0022 | 0.0334 | 0.0907 | 0.0339 |
| country_EIRE | 0.001 | 0.0174 | 0.0069 | 0.0072 |
| month_num | 6.00e-04 | 0.0135 | 0.0168 | 0.0113 |
| country_Cyprus | 2.00e-04 | 0.0035 | 0.0015 | 4.00e-04 |
| country_Netherlands | 2.00e-04 | 5.00e-04 | 0.0018 | 0.0012 |
| country_France | 1.00e-04 | 0.0025 | 0.0022 | 7.00e-04 |
| country_Germany | 1.00e-04 | 0.0027 | 0.0026 | 8.00e-04 |
| country_Spain | 1.00e-04 | 5.00e-04 | 0.0026 | 7.00e-04 |
This section summarizes the XGBoost classifier's predictive performance across all key evaluation metrics at a 0.5 decision threshold. It provides a comprehensive view of how well the model distinguishes between high-value and low-value transactions, serving as the primary indicator of model quality and reliability for deployment decisions.
The model exhibits exceptional performance across all standard classification metrics, indicating near-perfect separation of transaction value classes. The confusion matrix shows 4,876 true negatives and 4,831