Google Cloud Platform, Vertex AI, Machine Learning, Data Science, Hands On Tutorials.
customer has N purchases, we consider the Nth purchase as the target, and the N-1 as our features. We therefore exclude customers with only 1 purchase Let’s put that into code: # Compute recurrent customers recurrent_customers = df.groupby('user_id')['created_at'].count().to_frame("n_purchases") #