![train-test-split](https://i.imgur.com/ttegOuC.png)
![Codecov Status](https://codecov.io/gh/nas5w/train-test-split/branch/master/graph/badge.svg)
Split your dataset into training and test datasets.
Parameters
trainTestSplit(data, train, seed = null, indices = false);
- data: the array of data you intend to split.
- train: size of training set. If less than 1, assumed to be a fraction. E.g., a value of 0.8 will be interpreted as 80% while a value of 4 will be interpreted as 4 records.
- seed: when set, results will be repeatable if the same seed is used. I.e., the same dataset with the same seed will always yield the same train-test split.
- indices: indicates whether to return the indices of the provided array or the actual values.
Example usage
const trainTestSplit = require('train-test-split');
const arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
const [train, test] = trainTestSplit(arr, 0.8, 1234);
console.log(train, test);
const [trainIndices, testIndices] = trainTestSplit(arr, 0.8, 1234, true);
console.log(trainIndices, testIndices);