Baseline experiments for early session type classification using GA4 event data.
This repository contains the code and documentation for Experiment 1 of a research project on prefix-based session classification. The goal is to establish a reliable baseline using only minimal sequential input (event_name) before moving to richer feature representations and more complex models.
.
├── exp1_1.ipynb # Current Exp1 baseline (session-level class weights, seeds 42,123,456)
├── exp1_run1.ipynb # Previous Exp1 version First full run (seeds 42,123,456)
├── exp1_run2.ipynb # Previous Exp1 version Second full run (seeds 42,123,456)
├── exp1_run3.ipynb # Previous Exp1 version Third full run (seeds 42,123,456)
├── README.md # This file
└── requirements.txt # Python dependencies
- Data: Public GA4 sample dataset from BigQuery (
bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*) - Sessions: 360,129 sessions defined as
(user_pseudo_id, ga_session_id) - Task: Given the first
tevents of a session, predict the final session type (Buyer/Intent/Researcher/Browser) - Input: Only
event_name(no temporal or contextual features) - Models: Majority, Heuristic, Markov(1), SASRec (2-layer transformer)
- Split: Temporal (70% train, 15% validation, 15% test)
- Metric: Macro-F1 (prefix-level)
The only methodological change is how SASRec class weights are computed for CrossEntropyLoss:
- Previous runs (
*_prev): class weights computed from the train prefix-row label distribution - Current baseline (
exp1_sessionweights.ipynb): class weights computed from the train session-level label distribution (aligned with Exp2)
All SASRec results and diagnostics were re-generated after the change.
Current Exp1 baseline (session-level class weights):
| Model | Test Macro-F1 (mean ± std) |
|---|---|
| Majority | 0.1990 |
| Heuristic | 0.3761 |
| Markov(1) | 0.3186 |
| SASRec | 0.4176 ± 0.0011 |
Previous Exp1 versions (prefix-row class weights, 3-run aggregate):
| Model | Test Macro-F1 (mean ± std) |
|---|---|
| Majority | 0.199 |
| Heuristic | ≈0.376 |
| Markov(1) | ≈0.319 |
| SASRec | 0.564 ± 0.006 |
- SASRec improves over probabilistic baselines overall, but does not consistently dominate at every prefix length.
- Buyer and Intent remain difficult, and overall errors are strongly driven by generic navigation and engagement events (
page_view,user_engagement,scroll) plus future-dependent class identity (decisive events occur late). - The current sequence-only ceiling is substantially lower under session-level weighting, reinforcing the need for enriched signals in later experiments.
Key packages:
- torch ~= 2.0+
- scikit-learn ~= 1.2+
- pandas ~= 2.0+
- numpy ~= 1.23+
- matplotlib ~= 3.6+
- google-cloud-bigquery ~= 3.0+
Full list in requirements.txt.
MIT
- Google Cloud for providing the public GA4 sample dataset