Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/berkmann18/tvt-split
Train Validation Test split
https://github.com/berkmann18/tvt-split
machine-learning split test train validation
Last synced: 13 days ago
JSON representation
Train Validation Test split
- Host: GitHub
- URL: https://github.com/berkmann18/tvt-split
- Owner: Berkmann18
- Created: 2019-07-19T16:08:19.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-19T22:27:11.000Z (over 1 year ago)
- Last Synced: 2024-10-15T05:33:02.885Z (22 days ago)
- Topics: machine-learning, split, test, train, validation
- Language: JavaScript
- Size: 1.1 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![NPM](https://nodei.co/npm/tvt-split.png)](https://nodei.co/npm/tvt-split/)
[![GitHub package version](https://img.shields.io/github/package-json/v/Berkmann18/tvt-split.svg)](https://github.com/Berkmann18/tvt-split)
[![devDependencies Status](https://david-dm.org/berkmann18/tvt-split/dev-status.svg)](https://david-dm.org/berkmann18/tvt-split?type=dev)
[![dependencies Status](https://david-dm.org/berkmann18/tvt-split/status.svg)](https://david-dm.org/berkmann18/tvt-split)[![GH Downloads](https://img.shields.io/github/downloads/Berkmann18/tvt-split/total.svg)](https://github.com/Berkmann18/tvt-split/network/members)
[![GitHub commit activity the past year](https://img.shields.io/github/commit-activity/y/Berkmann18/tvt-split.svg)](https://github.com/Berkmann18/tvt-split/graphs/commit-activity)
[![GitHub contributors](https://img.shields.io/github/contributors/Berkmann18/tvt-split.svg)](https://github.com/Berkmann18/tvt-split/graphs/contributors)
[![Github search hit counter](https://img.shields.io/github/search/Berkmann18/tvt-split/goto.svg)](https://github.com/Berkmann18/tvt-split/graphs/traffic)[![Build Status](https://travis-ci.org/Berkmann18/tvt-split.svg?branch=master)](https://travis-ci.org/Berkmann18/tvt-split)
[![codecov.io Code Coverage](https://img.shields.io/codecov/c/github/Berkmann18/tvt-split.svg?maxAge=2592000)](https://codecov.io/github/Berkmann18/tvt-split?branch=master)
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
[![Known Vulnerabilities](https://snyk.io/test/github/Berkmann18/tvt-split/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Berkmann18/tvt-split?targetFile=package.json)[![GitHub](https://img.shields.io/github/license/Berkmann18/tvt-split.svg)](https://github.com/Berkmann18/tvt-split/blob/master/LICENSE)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/Berkmann18/tvt-split/issues)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)[![GitHub top language](https://img.shields.io/github/languages/top/Berkmann18/tvt-split.svg)](https://github.com/Berkmann18/tvt-split)
[![GitHub language count](https://img.shields.io/github/languages/count/Berkmann18/tvt-split.svg)](https://github.com/Berkmann18/tvt-split)
[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Berkmann18/tvt-split.svg)](https://github.com/Berkmann18/tvt-split)[![BCH compliance](https://bettercodehub.com/edge/badge/Berkmann18/tvt-split?branch=master)](https://bettercodehub.com/results/Berkmann18/tvt-split)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2a8e3e98d3bb47f29abbc3df7174675d)](https://app.codacy.com/app/maxieberkmann/tvt-split?utm_source=github.com&utm_medium=referral&utm_content=Berkmann18/tvt-split&utm_campaign=Badge_Grade_Dashboard)Split your dataset into training, validation and test datasets.
**This was largely inspired by [`train-test-split`](https://github.com/nas5w/train-test-split).**
## Install
```bash
npm install tvt-split
#or with Yarn
yarn add tvt-split
```## Documentation
#### Table of Contents
- [trainValidationTestSplit](#trainvalidationtestsplit)
- [Parameters](#parameters)### trainValidationTestSplit
Split data into a training, validation and test set.
#### Parameters
- `data` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Data
- `train` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Size of the training set (in percentage if `train < 1`)
- `validation` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Size of the validation set (in percentage if `train < 1`)
- `seed` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Seed of the Pseudo-Random Number Generation. (optional, default `-1.1`)
- `indices` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Indicates whether to return the indices of the provided array or the actual values (optional, default `false`)Returns **\[[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array), [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array), [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)]** Split data
## Example usage
```javascript
const tvts = require('tvt-split');const arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
const [train, validation, test] = tvts(arr, 0.8, .1, 1234);
console.log(train, validation, test);
// [ 'three', 'one', 'seven', 'eight', 'five', 'four', 'nine', 'six' ] [ 'two' ] [ 'ten' ]const [trainIndices, validationIndices, testIndices] = tvts(arr, 0.8, .1, 1234, true);
console.log(trainIndices, validationIndices, testIndices);
// [ 2, 0, 6, 7, 4, 3, 8, 5, ] [ 1 ] [ 9 ]
```