From 6d71719a8fa585bcb9c45e220a04338f199f6ac3 Mon Sep 17 00:00:00 2001 From: Johan <3921204+johan-mattias@users.noreply.github.com> Date: Mon, 19 Jan 2026 14:11:32 +0100 Subject: [PATCH] Add filter for 0 session lengths by filtering sessions with a zero length NaN values can be avoided --- ch07-prediction/feature_creation.R | 1 + 1 file changed, 1 insertion(+) diff --git a/ch07-prediction/feature_creation.R b/ch07-prediction/feature_creation.R index 34bc339..1825919 100644 --- a/ch07-prediction/feature_creation.R +++ b/ch07-prediction/feature_creation.R @@ -70,6 +70,7 @@ session_based_features <- function(events_data, current_week) { events_data |> filter(week <= current_week) |> distinct(user, session_id, session_len) |> + filter(session_len > 0) |> group_by(user) |> mutate(session_cnt = n(), avg_session_len = median(session_len),