-
Couldn't load subscription status.
- Fork 326
Time-Slice CV Class #2037
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
base: main
Are you sure you want to change the base?
Time-Slice CV Class #2037
Conversation
…g the date ranges (hence all geo levels for those dates) are kept.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2037 +/- ##
===========================================
- Coverage 92.86% 62.45% -30.42%
===========================================
Files 68 69 +1
Lines 9213 9596 +383
===========================================
- Hits 8556 5993 -2563
- Misses 657 3603 +2946 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks @timbo112711 ! I will look inot this one carefully this week :) |
| sampler_config: dict | None = None, | ||
| yaml_path: str | None = None, | ||
| mmm: Any | None = None, | ||
| ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing hint.
|
Hey, really nice implementation and critical feature we are missing! A few requests on my side:
This things align a lot more with the vision we are following right now with the class! Could you take a look? Otherwise, I can help you! @timbo112711 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new TimeSliceCrossValidator class to standardize time-slice cross-validation for Media Mix Models (MMM). Previously, users had to copy code from example notebooks; now they can use this scikit-learn-style class with methods like split(), get_n_splits(), and run().
Key Changes:
- New
TimeSliceCrossValidatorclass with configurablen_init,forecast_horizon,date_column, andstep_sizeparameters - Support for YAML-based model configuration or programmatic MMM instance passing
- Comprehensive test suite covering basic functionality, step_size variations, and edge cases
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pymc_marketing/mmm/time_slice_cross_validation.py |
Implements the core TimeSliceCrossValidator class with cross-validation logic and visualization methods |
tests/mmm/test_time_slice_cross_validator.py |
Comprehensive test suite validating initialization, splitting logic, model fitting, and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@cetagostini thanks for the review 🙌🏻! These make sense and I'll start working towards each of these. Will reach out if I need anything! |
Description
Currently to implement Time-Slice CV one would need to reference the example notebook and copy / pasta the code blocks. This PR aims to wrap the code inside the current notebook into a
TimeSliceCrossValidatorclass. This new class will be used to streamline how users implement this methodology.The class functions similar to the scikit-learn / generator approach for returning the spilts.
A simple flow would look the this,
Related Issue
Checklist
pre-commit.ci autofixto auto-fix.📚 Documentation preview 📚: https://pymc-marketing--2037.org.readthedocs.build/en/2037/