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

[Roadmap Pull Request] Add Optional Narwhals Backend-Agnostic strict_temporal_ordering for TimeFrame (#49) #50

Merged
merged 7 commits into from
Dec 9, 2024

Conversation

philip-ndikum
Copy link
Owner

@philip-ndikum philip-ndikum commented Dec 9, 2024

Pull Request

PR Type

  • ✨ Feature
  • 🧪 Test Addition/Update
  • 📚 Documentation Update

Description

This PR introduces the optional strict_temporal_ordering functionality for the TemporalScope library, addressing the need for backend-agnostic strict temporal validation. Key enhancements include:

  • strict_temporal_ordering function in core_utils.py:
    • Validates global or group-specific temporal ordering and uniqueness.
    • Ensures robust data assumptions for partitioning and downstream modeling.
  • Enhancements to the TimeFrame class:
    • Introduced the strict_temporal_order parameter for optional strict validation.
    • Logs warnings when strict temporal validation is not enabled.
  • Unit Test Coverage:
    • Comprehensive tests for edge cases, ensuring robust handling of global and group-level validations.
  • Documentation and Tutorial Updates:
    • Updated notebooks and integration tests to demonstrate the new functionality.
    • Added detailed examples showcasing strict temporal validation.

These changes align with the roadmap, ensuring TemporalScope supports modern ML/DL workflows while remaining flexible for exploratory/scientific research and mixed-frequency use cases.

Related Issues

Testing

Added/Updated Tests

  • Yes
  • No, and here's why:
  • I need help writing tests

How Has This Been Tested?

This feature has been validated through:

  • Unit Tests: Cover edge cases for both global and group-level temporal validations.
  • Integration Tests: Ensure seamless integration with the TimeFrame class and partitioning functions.
  • Tutorials: Validated examples in Jupyter notebooks.

Test Configuration

  • Python version: 3.11.10
  • Operating System: macOS
  • Pre-commit hooks: All checks passed successfully.

Checklist

  • I have read the contributors guidelines and code of conduct
  • I have updated the documentation accordingly.
  • I have added/updated tests as appropriate.
  • I have updated the related issue(s) with new insights and changes.
  • I have used a conventional commit type in my PR title.
  • I have run pre-commit hooks and fixed any issues.

Additional Notes

This enhancement bridges the gap between flexible mixed-frequency workflows and scenarios requiring rigorous temporal guarantees. It ensures backward compatibility, with strict validation being entirely opt-in.

…namespaces

- Established consistent namespace structure for partitioning workflows.
- Added static and dynamic directories with clear documentation.
- Removed redundant files and organized padding functionality into single_target namespace.
…oner

- Added reusable utility functions in `utils.py` for single-target partitioning workflows.
- Implemented `SlidingWindowPartitioner` with dynamic validation and verbose configuration.
- Included validation for train, test, and validation percentages and cardinality checks.
- Prepared for seamless integration with future algorithms like `ExpandingWindowPartitioner` and similar implementations.
…core_utils with 100% coverage

- implemented strict temporal ordering logic in core_utils.py and integrated it into temporal_data_loader.py
- refactored `validate_dataframe_column_types` to ensure `time_col` supports numeric or datetime types and all other columns are numeric
- updated unit tests in `test_core_utils.py` to align with the updated validation function
- removed redundant `nw.from_native` in tests, ensuring Narwhals API handles conversions natively
- improved code coverage in `temporal_data_loader.py` and adjusted unit tests for partition utilities
- resolved regex mismatches in tests for error validation messages
- maintained a clean modular design by centralizing validation in core_utils.py, facilitating reuse and ensuring consistency across the codebase
…o be at 100% refactoring some bugs in previous sorting logic when given an id_col

- Fixed logic for sorting validation
…alidation

feat(core): add optional strict temporal ordering and enhance validation

- Introduced `strict_temporal_ordering` functionality for backend-agnostic validation of global or group-specific temporal ordering and uniqueness.
- Extended the `TimeFrame` class with the `strict_temporal_order` parameter to optionally enforce rigorous temporal validation.
- Updated `core_utils` with utility functions supporting strict temporal ordering and group-level uniqueness checks.
- Enhanced test coverage to 100%, covering all edge cases for new and existing features.
- Updated tutorials and integration tests to reflect the new functionality.
- Removed outdated tests and ensured full compliance with modern Narwhals backend compatibility.

This enhancement bridges the gap between flexible mixed-frequency workflows and scenarios requiring strict temporal guarantees, aligning with the library's core philosophy.
…dated tutorial to show output for new end-users
@coveralls
Copy link

Coverage Status

coverage: 96.693% (+2.7%) from 94.041%
when pulling 005b246 on feature/partition-narwhals-compatibility-41
into 222bdd9 on main.

@philip-ndikum philip-ndikum changed the title Feature/partition narwhals compatibility 41 [Roadmap] Add Optional Narwhals Backend-Agnostic strict_temporal_ordering for TimeFrame (#49) Dec 9, 2024
@philip-ndikum philip-ndikum changed the title [Roadmap] Add Optional Narwhals Backend-Agnostic strict_temporal_ordering for TimeFrame (#49) [Roadmap Pull Request] Add Optional Narwhals Backend-Agnostic strict_temporal_ordering for TimeFrame (#49) Dec 9, 2024
@philip-ndikum philip-ndikum merged commit e7cea82 into main Dec 9, 2024
2 checks passed
@philip-ndikum philip-ndikum deleted the feature/partition-narwhals-compatibility-41 branch December 9, 2024 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Roadmap] Add Optional Narwhals Backend Agnostic strict_temporal_ordering for TimeFrame
2 participants