{"id":13570959,"url":"https://github.com/WenjieZ/TSCV","last_synced_at":"2025-04-04T07:32:30.245Z","repository":{"id":34881149,"uuid":"186586661","full_name":"WenjieZ/TSCV","owner":"WenjieZ","description":"Time Series Cross-Validation -- an extension for scikit-learn","archived":false,"fork":false,"pushed_at":"2023-01-23T18:52:33.000Z","size":229,"stargazers_count":253,"open_issues_count":3,"forks_count":42,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-06T21:02:20.981Z","etag":null,"topics":["backtesting","cross-validation","data-science","hyperparameter-optimization","machine-learning","model-selection","time-series","tuning-parameters"],"latest_commit_sha":null,"homepage":"https://tscv.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WenjieZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-14T09:10:38.000Z","updated_at":"2025-01-01T23:23:48.000Z","dependencies_parsed_at":"2023-02-13T02:15:48.125Z","dependency_job_id":null,"html_url":"https://github.com/WenjieZ/TSCV","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WenjieZ%2FTSCV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WenjieZ%2FTSCV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WenjieZ%2FTSCV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WenjieZ%2FTSCV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WenjieZ","download_url":"https://codeload.github.com/WenjieZ/TSCV/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247139206,"owners_count":20890184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtesting","cross-validation","data-science","hyperparameter-optimization","machine-learning","model-selection","time-series","tuning-parameters"],"created_at":"2024-08-01T14:00:56.873Z","updated_at":"2025-04-04T07:32:25.226Z","avatar_url":"https://github.com/WenjieZ.png","language":"Python","funding_links":[],"categories":["📦 Packages"],"sub_categories":["Python"],"readme":"[![Downloads](https://pepy.tech/badge/tscv/month)](https://pepy.tech/project/tscv)\n[![Build Status](https://travis-ci.com/WenjieZ/TSCV.svg?branch=master)](https://travis-ci.com/WenjieZ/TSCV)\n[![codecov](https://codecov.io/gh/WenjieZ/TSCV/branch/master/graph/badge.svg?token=dcGlEfHCw2)](https://codecov.io/gh/WenjieZ/TSCV)\n[![Documentation Status](https://readthedocs.org/projects/tscv/badge/?version=latest)](https://tscv.readthedocs.io/en/latest/?badge=latest)\n[![DOI](https://zenodo.org/badge/186586661.svg)](https://zenodo.org/badge/latestdoi/186586661)\n\n![](train-gap-test.svg)\n\n# TSCV: Time Series Cross-Validation\n\nThis repository is a [scikit-learn](https://scikit-learn.org) extension for time series cross-validation.\nIt introduces **gaps** between the training set and the test set, which mitigates the temporal dependence of time series and prevents information leakage.\n\n## Installation\n\n```bash\npip install tscv\n```\n\nor\n\n```bash\nconda install -c conda-forge tscv\n```\n\n## Usage\n\nThis extension defines 3 cross-validator classes and 1 function:\n- `GapLeavePOut`\n- `GapKFold`\n- `GapRollForward`\n- `gap_train_test_split`\n\nThe three classes can all be passed, as the `cv` argument, to\nscikit-learn functions such as `cross-validate`, `cross_val_score`,\nand `cross_val_predict`, just like the native cross-validator classes.\n\nThe one function is an alternative to the `train_test_split` function in `scikit-learn`.\n\n## Examples\n\nThe following example uses `GapKFold` instead of `KFold` as the cross-validator.\n```python\nimport numpy as np\nfrom sklearn import datasets\nfrom sklearn import svm\nfrom sklearn.model_selection import cross_val_score\nfrom tscv import GapKFold\n\niris = datasets.load_iris()\nclf = svm.SVC(kernel='linear', C=1)\n\n# use GapKFold as the cross-validator\ncv = GapKFold(n_splits=5, gap_before=5, gap_after=5)\nscores = cross_val_score(clf, iris.data, iris.target, cv=cv)\n```\n\nThe following example uses `gap_train_test_split` to split the data set into the training set and the test set.\n```python\nimport numpy as np\nfrom tscv import gap_train_test_split\n\nX, y = np.arange(20).reshape((10, 2)), np.arange(10)\nX_train, X_test, y_train, y_test = gap_train_test_split(X, y, test_size=2, gap_size=2)\n```\n\n## Contributing\n- Report bugs in the issue tracker\n- Express your use cases in the issue tracker\n\n## Documentations\n- [tscv.readthedocs.io](https://tscv.readthedocs.io)\n\n## Acknowledgments\n\n- I would like to thank Jeffrey Racine and Christoph Bergmeir for the helpful discussion.\n\n## License\nBSD-3-Clause\n\n## Citation\n\nWenjie Zheng. (2021). Time Series Cross-Validation (TSCV): an extension for scikit-learn. Zenodo. http://doi.org/10.5281/zenodo.4707309\n\n```latex\n@software{zheng_2021_4707309,\n  title={{Time Series Cross-Validation (TSCV): an extension for scikit-learn}},\n  author={Zheng, Wenjie},\n  month={april},\n  year={2021},\n  publisher={Zenodo},\n  doi={10.5281/zenodo.4707309},\n  url={http://doi.org/10.5281/zenodo.4707309}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWenjieZ%2FTSCV","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWenjieZ%2FTSCV","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWenjieZ%2FTSCV/lists"}