Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a transformer to sessionize a table #750

Open
jeromedockes opened this issue Sep 22, 2023 · 5 comments
Open

Adding a transformer to sessionize a table #750

jeromedockes opened this issue Sep 22, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@jeromedockes
Copy link
Member

Problem Description

In a table representing events with timestamps, it is often useful to detect sessions -- groups of events that occurred close to each other.

For example, a few visits to the hospital a few days apart are likely to be exams and follow-ups related to the same medical event. Or we may want to detect when a user walks away from an app, website, service etc and later comes back to it. Then features like number of sessions, session length etc can be extracted.

Examples from Ibis, polars and SODA using logs from a video game:

https://ibis-project.org/how-to/timeseries/sessionize
https://www.pola.rs/posts/the-expressions-api-in-polars-is-amazing/
https://github.com/soda-inria/survival-analysis-benchmark/blob/main/notebooks/tutorial_part_2.py

Would it be in the scope of skrub to have a transformer that adds a "session id" column to a dataframe, and maybe extracts some features such as session length?

Feature Description

transform a table by detecting sessions and adding related information

Alternative Solutions

No response

Additional Context

No response

@jeromedockes jeromedockes added the enhancement New feature or request label Sep 22, 2023
@koaning
Copy link

koaning commented Feb 26, 2024

I wouldn't mind working on this if folks agree. This session stuff is the the prime villain in any story about data leakage in ML pipelines.

@GaelVaroquaux
Copy link
Member

GaelVaroquaux commented Feb 26, 2024 via email

@jeromedockes
Copy link
Member Author

@koaning part of the changes Gaël mentions is being worked on in #877
Feel free to provide feedback and advice!

@koaning
Copy link

koaning commented May 21, 2024

One observation since responding to this all those months ago ...

Do we generally want to add sessions to the dataset before calling train/test split? I think we might! The session may be what we need in order to split events into groups which define the train/test splits. If that's the case ... do we want to have a pipeline that runs before we split train/test?

@GaelVaroquaux
Copy link
Member

GaelVaroquaux commented May 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants