Date-aware time series cross-validator for deterministic train/test splits.
Project description
TimeSeriesSplitByDate
Date-aware splitting utility for time series model evaluation.
Installation
pip install timeseriessplitbydate
For local development:
pip install -e .
Quickstart
import pandas as pd
from timeseriessplitbydate import TimeSeriesSplitByDate
X = pd.DataFrame(
{
"feature": range(8),
"event_date": pd.date_range("2024-01-01", periods=8, freq="D"),
}
)
splitter = TimeSeriesSplitByDate(
n_splits=3,
date_col="event_date",
split_by="days",
)
for train_idx, test_idx in splitter.split(X):
print(train_idx, test_idx)
How it differs from sklearn TimeSeriesSplit
- Supports date-column-driven splitting (
date_col) for DataFrame inputs. - Adds calendar-aware modes:
split_by="days": equal-width date-range intervals.split_by="weeks": adjacent week folds withweek_start="monday"(default) orweek_start="sunday".split_by="months": adjacent month folds.
- Supports external date data via
set_date_data(...). - Falls back to sklearn
TimeSeriesSplitwhen no date source is provided. - In date-based modes,
gapis interpreted as calendar days.
Development
pip install -e .[dev]
ruff check .
pytest
More Documentation
- Usage guide:
docs/usage.md - Runnable demo:
examples/basic_usage.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file timeseriessplitbydate-0.1.0.tar.gz.
File metadata
- Download URL: timeseriessplitbydate-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a90750dc2243cce067f9afd57b5ac89d97b8e7fec2209a1e68fed1072e3bc12
|
|
| MD5 |
61d55b86c45b71ca5cb4ebb8032954a1
|
|
| BLAKE2b-256 |
3cd66de99695f8655bb8512625b021bd1905a6c3dea4ca07bdbd5556f75c222b
|
File details
Details for the file timeseriessplitbydate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: timeseriessplitbydate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3908a5177fac6eb3d5780b14cad51f6a8444017283ac99965a51fc6fbd3fb736
|
|
| MD5 |
30685d0a820fe1e0b66de1a5877b8c11
|
|
| BLAKE2b-256 |
96dc880ea1dc53ab2bf9bcad92a7afd1222c0ac5afbe1bbae87086bc501d324b
|