-
Notifications
You must be signed in to change notification settings - Fork 5
TpT #80
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?
TpT #80
Conversation
Introduced temporal-penalized splitting (TpT) for regression tasks. Added handling of features_group parameter to align with classifier implementation. Ensured regressor leverages the new TpTSplitter from scikit-lexicographical-trees. Updated initialization and validation logic for compatibility with Phase 1b changes (wave index / split_time_index propagation).
Added support for features_group parameter in TpTDecisionTreeClassifier to enable temporal penalization and lexicographic splitting. Updated fit method to enforce presence of features_group and ensure consistent initialization. Integrated calls to the updated TpTSplitter from scikit-lexicographical-trees. Improved docstring with guidance for preparing longitudinal input data.
- Removed specific version constraints for `scikit-lexicographical-trees` and `ray` in `pyproject.toml`. -> Maybe Simon can find a way to bypass that ? - Added local path for `scikit-lexicographical-trees` in the `tool.uv.sources` section. -> I do not know if we should keep it this way ? - Updated `uv.lock` with new versions for several packages, including `anyio`, `argon2-cffi`, `arrow`, `astroid`, `typing-extensions`, `tzdata`, `urllib3`, `wcwidth`, `websocket-client`, `widgetsnbextension`, and `zipp`. - Refactored `TpT` tree estimators to improve code organization and clarity, including the addition of a public namespace for `TpT` estimators and enhancements to the `TpTDecisionTreeClassifier` and `TpTDecisionTreeRegressor` classes for better handling of long-format data. TO DO: Clean everything (get rid of all tests datasets)
|
@MathiasValla Your work is amazing! Thanks so very much! Happy new year as well! I will be busy in the coming weeks / months but as always as soon as I can I'll work on making this PR ready — Some news incoming within the year for Sklong (positive!); and TpT will definitely be useful :) Wishing you well, Cheers |
|
@simonprovost Thanks, bets wishes to you too ! Great to hear. In the meantime, I still need to finalize 2 articles on TpT, where I'll refer to sklong, of course. I'm also working on an animation explaining how TpT works (animated with manim), it could be usefull to include it on the scikit-longitudinal website (if you also think it's a good idea). Cheers, |
You are working so efficiently @MathiasValla ! Kind of jealous 🙏 That's fantastic to hear, and thank you for your kind gesture, mate! I am very interested! I would be pleased, as I have great trust in your research. If you want to continue the discussion by email regarding adding me as the (last) co-author of your manuscript, please do so 🫡. I suppose I'll be more transparent so you're aware. In two weeks, I'll begin a Longitudinal ML-based research visit at the University of Edinburgh, and in the meantime, I'm applying here and there arounds for Post-Docs and trying to finish writing my Ph.D. thesis, so the faster I get, the more time I'll have to work on TpT integration. This being said, given your journal wishes, I believe I could spend time on TpT in a month or so. Perhaps set yourself a reminder (I wish there was bots agents in Github Issues 👀 that could chase meself) and chase back, saying, "Hey Simon, you are late:)"? My head tends to be everywhere at once... This is a fantastic idea the TpT animation. I had in mind last year to create a visualisation for each of Sklong's primitives at the top of their respective API reference page so that users could grasp them easily. Definitely include it, or give it to me and I'll include it in the API ref of TpT; it's a modern documentation notion that I plan (during my Post-Doc) to extend to others so be the first one with TpT :) PS: I adore Manim! Look here: Let us keep each other transparently updated Cheers, |
Hi Simon,
I’m happy to share that the TpT implementation is now finalized code-wise on my side. This MR introduces a working
TpTDecisionTreeClassifierwith a depth-first builder, compatible with scikit-lexicographical-trees / scikit-longitudinal.References to cite
[1] Valla, M. Time-penalised trees (TpT): introducing a new tree-based data mining algorithm for time-varying covariates. Ann Math Artif Intell 92, 1609–1661 (2024). https://doi.org/10.1007/s10472-024-09950-w
[2] Mathias Valla, Xavier Milhaud. Time-penalized trees: consistency results and simulations. 2025. ⟨hal-05022929⟩ https://cnrs.hal.science/hal-05022929
Scope of this PR (minimal, functional)
TpTDecisionTreeClassifier(classification only in this PR’s target scope).DepthFirstTreeBuilder(no Best-First in this scope).plot_treeadaptation included here; regularsklearn.tree.plot_treeis usable for quick inspection.)Where the code lives
scikit_longitudinal/estimators/trees/TpT/(primary class:
TpTDecisionTreeClassifier, splitter, builder, structs)scikit_longitudinal/estimators/trees/TpT/_preprocessing.pyThis should be moved under or near
LongitudinalDatasetper your design. I’d be grateful if you could drop it into the right place in a temporary branch; I’ll review once moved. It currently handles long → wide only (not the reverse), without TIDAL/polars. It’s a first step toward 💡 Feature Request - From Wide to Long and vice-versa Longitudinal data formatting, inspired from TIDAL #64 but does not fully solve it.Quick example (concise)
That’s intentionally minimal (no non-essential utilities, no external metrics). It just loads data, fits TpT, prints a few structural fields, and plots.
Dependencies
rayfrom the dependencies due to local issues.Please feel free to restore it where appropriate (e.g., as an optional dependency / extra for parallelism or tests).
Ask / next steps
I’ve pushed this as far as I can right now. It would be ideal if you could manage the integration so TpT aligns perfectly with sklong’s patterns (API surface, dataset plumbing via
LongitudinalDataset, docs structure, examples, CI, etc.). I’ll follow up with any fixes you need during review.I’m also working on two additional papers involving TpT and will of course cite scikit-longitudinal as the reference implementation. For any future article specifically about the implementation, I’d be happy to include you as co-author for your guidance and help.
Thanks a lot, and please let me know how you’d like to proceed with the preprocessing relocation!
— Mathias