---
name: "mlpack_preprocess_split"
section: "1"
platform: "linux"
package: "mlpack-bin"
version: "4.6.0-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mlpack_preprocess_split"
---

# mlpack\_preprocess\_split(1)

split data

## NAME

**mlpack\_preprocess\_split** - split data

## SYNOPSIS

```
 mlpack_preprocess_split -i unknown [-I unknown] [-S bool] [-s int] [-z bool] [-r double] [-V bool] [-T unknown] [-L unknown] [-t unknown] [-l unknown] [-h -v]
```

## DESCRIPTION

This utility takes a dataset and optionally labels and splits them into a training set and a test set. Before the split, the points in the dataset are randomly reordered. The percentage of the dataset to be used as the test set can be specified with the '**--test\_ratio** (**-r**)' parameter; the default is 0.2 (20%).

The output training and test matrices may be saved with the '**--training\_file** (**-t**)' and '**--test\_file** (**-T**)' output parameters.

Optionally, labels can also be split along with the data by specifying the ’**--input\_labels\_file** (**-I**)' parameter. Splitting labels works the same way as splitting the data. The output training and test labels may be saved with the ’**--training\_labels\_file** (**-l**)' and '**--test\_labels\_file** (**-L**)' output parameters, respectively.

So, a simple example where we want to split the dataset 'X.csv' into ’X\_train.csv' and 'X\_test.csv' with 60% of the data in the training set and 40% of the dataset in the test set, we could run

$ **mlpack\_preprocess\_split** **--input\_file** X.csv **--training\_file** X\_train.csv **--test\_file** X\_test.csv **--test\_ratio** 0.4

Also by default the dataset is shuffled and split; you can provide the ’**--no\_shuffle** (**-S**)' option to avoid shuffling the data; an example to avoid shuffling of data is:

$ **mlpack\_preprocess\_split** **--input\_file** X.csv **--training\_file** X\_train.csv **--test\_file** X\_test.csv **--test\_ratio** 0.4 **--no\_shuffle**

If we had a dataset 'X.csv' and associated labels 'y.csv', and we wanted to split these into 'X\_train.csv', 'y\_train.csv', 'X\_test.csv', and 'y\_test.csv', with 30% of the data in the test set, we could run

$ **mlpack\_preprocess\_split** **--input\_file** X.csv **--input\_labels\_file** y.csv **--test\_ratio** 0.3 **--training\_file** X\_train.csv **--training\_labels\_file** y\_train.csv **--test\_file** X\_test.csv **--test\_labels\_file** y\_test.csv

To maintain the ratio of each class in the train and test sets, the'**--stratify\_data** (**-z**)' option can be used.

$ **mlpack\_preprocess\_split** **--input\_file** X.csv **--training\_file** X\_train.csv **--test\_file** X\_test.csv **--test\_ratio** 0.4 **--stratify\_data**

## REQUIRED INPUT OPTIONS

- **--input\_file (-i) \[*unknown*\]**

  Matrix containing data.

## OPTIONAL INPUT OPTIONS

- **--help (-h) \[*bool*\]**

  Default help info.

- **--info \[string\]**

  Print help on a specific option. Default value ''.

- **--input\_labels\_file (-I) \[*unknown*\]**

  Matrix containing labels.

- **--no\_shuffle (-S) \[*bool*\]**

  Avoid shuffling the data before splitting.

- **--seed (-s) \[*int*\]**

  Random seed (0 for **std::time**(NULL)). Default value 0.

- **--stratify\_data (-z) \[*bool*\]**

  Stratify the data according to labels

- **--test\_ratio (-r) \[*double*\]**

  Ratio of test set; if not set,the ratio defaults to 0.2 Default value 0.2.

- **--verbose (-v) \[*bool*\]**

  Display informational messages and the full list of parameters and timers at the end of execution.

- **--version (-V) \[*bool*\]**

  Display the version of mlpack.

## OPTIONAL OUTPUT OPTIONS

- **--test\_file (-T) \[*unknown*\]**

  Matrix to save test data to.

- **--test\_labels\_file (-L) \[*unknown*\]**

  Matrix to save test labels to.

- **--training\_file (-t) \[*unknown*\]**

  Matrix to save training data to.

- **--training\_labels\_file (-l) \[*unknown*\]**

  Matrix to save train labels to.

## ADDITIONAL INFORMATION

For further information, including relevant papers, citations, and theory, consult the documentation found at http://www.mlpack.org or included with your distribution of mlpack.
