CLASSIFICATION STUDY · 2026

Online Shopper
Purchase Intention
Prediction

A comparative machine learning study predicting whether an e-commerce browsing session will result in revenue.

RtidyversecaretrandomForestXGBoostpROC

RESEARCH OVERVIEW

Can browsing behaviour reveal purchase intent?

The study uses session-level behavioural and technical attributes to distinguish purchasers from non-purchasers. Because only 15.63% of cleaned sessions produced revenue, accuracy alone would be misleading; the analysis prioritised ROC-AUC, balanced accuracy, recall, precision, and F1.

RQ

Research questionWhich supervised machine learning technique most effectively predicts online purchase intention from session behaviour?

01 · DATASET

From raw sessions to reliable evidence.

Original rows12,33018 total variables
Duplicates removed1251.01% · all non-purchases
Cleaned rows12,20517 predictors + target
Missing values0No imputation required

Target distribution

Revenue is strongly imbalanced.

The majority baseline reaches 84.38% accuracy while detecting zero purchases—showing why accuracy cannot be the only success measure.
10,297 No purchase84.37%
1,908 Purchase15.63%

02 · EXPLORATORY ANALYSIS

What the sessions reveal.

01

New visitors convert more

24.9%

New visitors had a higher purchase rate than returning visitors at 14.1%.

02

November leads conversion

25.5%

The monthly purchase rate peaked in November, compared with only 1.66% in February.

03

Page value dominates

#1

PageValues was the most important predictor in all three fitted models.

04

Non-normal behaviour

10/10

Every numerical variable showed evidence of non-normality in sampled Shapiro-Wilk tests.

MONTHLY PURCHASE RATE

Conversion rises toward November.

1.66%Feb
10.3%Mar
11%May
10.2%Jun
15.3%Jul
17.6%Aug
19.2%Sep
21%Oct
25.5%Nov
12.7%Dec

Strongest paired correlations

Informational ↔ Duration0.9508
Administrative ↔ Duration0.9393
Product pages ↔ Duration0.8792

Chi-square findings

Monthp < .001
Traffic typep < .001
Visitor typep < .001
Regionp = .288

03 · METHODOLOGY

A reproducible comparison.

01Import & validateSchema checks on 18 expected columns
02Clean & encodeDuplicates removed; categorical factors
03Stratified split70% train · 30% test
04Train & tuneRepeated 5-fold CV × 3
05EvaluateSeven classification metrics
CLASS IMBALANCE

Up-sampling and weighting

caret models used up-sampling within resampling. XGBoost used a positive-class weight of 5.395 to give purchase sessions appropriate influence.

REPRODUCIBILITY

Controlled experimentation

A fixed random seed of 12345, stratified data partitioning, saved cross-validation predictions, and parallel processing supported repeatable comparisons.

MODEL SELECTION

ROC-AUC as primary metric

The minority purchase class and asymmetric business value made discrimination and recall more useful than raw accuracy alone.

04 · MODEL PERFORMANCE

Three models. Different strengths.

SELECTED MODEL

XGBoost

0.9296TEST ROC-AUC

Best overall discrimination and purchase recall.

MetricScorePerformance
Accuracy0.8571
Balanced accuracy0.8555
Precision0.5264
Recall0.8531
Specificity0.8579
F1 score0.6511
ROC-AUC0.9296
ModelAccuracyBalanced accuracyPrecisionRecallF1ROC-AUCCV AUC
XGBoost BEST AUC0.85710.85550.52640.85310.65110.92960.9329
Random Forest 0.89320.80280.65420.67130.66260.9240.9291
Logistic Regression 0.84130.80410.49480.750.59620.8920.8998

05 · INTERPRETATION

Page value drives the prediction.

PageValues100
Month · November20.5
ProductRelated28.2
BounceRates27.3
ExitRates25.7
Product duration24.9
Administrative23.5
Visitor type13.8
KEY FINDING

Engagement quality matters more than simple volume.

PageValues was overwhelmingly influential, while exit behaviour, product engagement, month, traffic source, and visitor type added useful signals. The result suggests that where visitors navigate—and the commercial value of those pages—matters more than page counts alone.

“The strongest model is not necessarily the one with the highest accuracy; it is the one that best supports the prediction objective.”

06 · CONCLUSION

XGBoost provided the best overall purchase-intention discrimination.

With a test ROC-AUC of 0.9296 and recall of 0.8531, XGBoost was selected as the best model by the study’s primary criterion. Random Forest remained valuable where precision and specificity were more important.

The analysis also shows why class-aware evaluation is essential: the majority baseline appeared accurate at 84.38% but failed to identify a single purchasing session.

Back to data science projects →