{"id":15655197,"url":"https://github.com/mayer79/splittools","last_synced_at":"2025-08-21T01:32:08.117Z","repository":{"id":44713431,"uuid":"231576210","full_name":"mayer79/splitTools","owner":"mayer79","description":"Light weight R package to do fast data splitting for cross-validation or train/valid/test splits","archived":false,"fork":false,"pushed_at":"2025-04-06T09:21:24.000Z","size":1041,"stargazers_count":13,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T10:20:24.377Z","etag":null,"topics":["cross-validation","machine-learning","rstats","time-series","validation"],"latest_commit_sha":null,"homepage":"https://mayer79.github.io/splitTools/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mayer79.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-03T11:44:20.000Z","updated_at":"2025-04-06T09:18:34.000Z","dependencies_parsed_at":"2022-08-29T05:30:21.896Z","dependency_job_id":"8d1029cc-9954-49d3-9b2b-96cb5e5190f0","html_url":"https://github.com/mayer79/splitTools","commit_stats":{"total_commits":65,"total_committers":3,"mean_commits":"21.666666666666668","dds":"0.23076923076923073","last_synced_commit":"7b6c868ac9d80fb03f02701fecd287a7ce6a3056"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/mayer79/splitTools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2FsplitTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2FsplitTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2FsplitTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2FsplitTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mayer79","download_url":"https://codeload.github.com/mayer79/splitTools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayer79%2FsplitTools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271415019,"owners_count":24755628,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cross-validation","machine-learning","rstats","time-series","validation"],"created_at":"2024-10-03T12:56:58.535Z","updated_at":"2025-08-21T01:32:08.111Z","avatar_url":"https://github.com/mayer79.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# {splitTools} \u003ca href='https://github.com/mayer79/splitTools'\u003e\u003cimg src='man/figures/logo.png' align=\"right\" height=\"139\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/mayer79/splitTools/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mayer79/splitTools/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/mayer79/splitTools/graph/badge.svg)](https://app.codecov.io/gh/mayer79/splitTools)\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/splitTools)](https://cran.r-project.org/package=splitTools)\n\n[![](https://cranlogs.r-pkg.org/badges/splitTools)](https://cran.r-project.org/package=splitTools) \n[![](https://cranlogs.r-pkg.org/badges/grand-total/splitTools?color=orange)](https://cran.r-project.org/package=splitTools)\n\n\u003c!-- badges: end --\u003e\n\n## Overview\n\n{splitTools} is a toolkit for fast data splitting. It does not have any dependencies. \n\nIts two main functions `partition()` and `create_folds()` support\n\n- data partitioning (e.g. into training, validation and test),\n- creating (in- or out-of-sample) folds for cross-validation (CV),\n- creating *repeated* folds for CV,\n- stratified splitting, \n- grouped splitting as well as\n- blocked splitting (if the sequential order of the data should be retained).\n\nThe function `create_timefolds()` does time-series splitting where the out-of-sample data follows the (extending or moving) in-sample data.\n\nThe result of `create_folds()` can be directly passed to the `folds` argument in CV functions of XGBoost or LightGBM. Since these functions expect *out-of-sample* indices, set the option `invert = TRUE`.\n\n## Installation\n\n```r\n# From CRAN\ninstall.packages(\"splitTools\")\n\n# Development version\ndevtools::install_github(\"mayer79/splitTools\")\n```\n\n## Usage\n\n``` r\nlibrary(splitTools)\n\np \u003c- c(train = 0.5, valid = 0.25, test = 0.25)\n\n# Train/valid/test indices for iris data stratified by Species\nstr(inds \u003c- partition(iris$Species, p, seed = 1))\n\n# List of 3\n#  $ train: int [1:73] 1 3 5 7 8 10 12 13 14 15 ...\n#  $ valid: int [1:38] 4 9 19 21 27 28 29 30 32 35 ...\n#  $ test : int [1:39] 2 6 11 16 18 22 26 37 38 40 ...\n\n# Same, but different output interface\nhead(inds \u003c- partition(iris$Species, p, split_into_list = FALSE, seed = 1))\n\n# [1] train test  train valid train test \n# Levels: train valid test\n\n# In-sample indices for 5-fold CV (stratified by Species)\nstr(inds \u003c- create_folds(iris$Species, k = 5, seed = 1))\n\n# List of 5\n#  $ Fold1: int [1:120] 2 4 5 6 7 8 9 10 11 15 ...\n#  $ Fold2: int [1:120] 1 2 3 4 5 6 9 10 11 12 ...\n#  $ Fold3: int [1:120] 1 2 3 4 6 7 8 9 11 12 ...\n#  $ Fold4: int [1:120] 1 3 5 6 7 8 10 11 12 13 ...\n#  $ Fold5: int [1:120] 1 2 3 4 5 7 8 9 10 12 ...\n\n# In-sample indices for 3 times repeated 5-fold CV (stratified by Species)\nstr(inds \u003c- create_folds(iris$Species, k = 5, m_rep = 3, seed = 1))\n\n# List of 15\n#  $ Fold1.Rep1: int [1:120] 2 4 5 6 7 8 9 10 11 15 ...\n#  $ Fold2.Rep1: int [1:120] 1 2 3 4 5 6 9 10 11 12 ...\n#  $ Fold3.Rep1: int [1:120] 1 2 3 4 6 7 8 9 11 12 ...\n#  $ Fold4.Rep1: int [1:120] 1 3 5 6 7 8 10 11 12 13 ...\n#  $ Fold5.Rep1: int [1:120] 1 2 3 4 5 7 8 9 10 12 ...\n#  $ Fold1.Rep2: int [1:120] 1 2 3 4 5 6 8 9 11 12 ...\n#  $ Fold2.Rep2: int [1:120] 1 3 6 7 8 9 10 12 13 14 ...\n# [...]\n\n# Indices for time-series splitting\nstr(inds \u003c- create_timefolds(1:100, k = 5))\n\n# List of 5\n# $ Fold1:List of 2\n#  ..$ insample : int [1:17] 1 2 3 4 5 6 7 8 9 10 ...\n#  ..$ outsample: int [1:17] 18 19 20 21 22 23 24 25 26 27 ...\n# $ Fold2:List of 2\n#  ..$ insample : int [1:34] 1 2 3 4 5 6 7 8 9 10 ...\n#  ..$ outsample: int [1:17] 35 36 37 38 39 40 41 42 43 44 ...\n# $ Fold3:List of 2\n# [...]\n```\n\nFor more details, check out the vignette.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayer79%2Fsplittools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayer79%2Fsplittools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayer79%2Fsplittools/lists"}