# train_test_split

### cuml.model_selection.train_test_split(\*arrays, test_size=None, train_size=None, random_state=None, shuffle=True, stratify=None)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/model_selection/_split.py#L20)

Split arrays or matrices into random train and test subsets.

* **Parameters:**
  **\*arrays**
  : Allowed inputs are cudf DataFrames/Series, cupy arrays, numpy arrays,
    pandas DataFrames/Series, or any array-like objects with a shape
    attribute.

  **test_size**
  : If float, should be between 0.0 and 1.0 and represent the proportion
    of the dataset to include in the test split. If int, represents the
    absolute number of test samples. If None, the value is set to the
    complement of the train size. If train_size is also None, it will
    be set to 0.25.

  **train_size**
  : If float, should be between 0.0 and 1.0 and represent the
    proportion of the dataset to include in the train split. If
    int, represents the absolute number of train samples. If None,
    the value is automatically set to the complement of the test size.

  **random_state**
  : Controls the shuffling applied to the data before applying the split.
    Pass an int for reproducible output across multiple function calls.

  **shuffle**
  : Whether or not to shuffle the data before splitting.

  **stratify**
  : If not None, data is split in a stratified fashion, using this as
    the class labels.
* **Returns:**
  **splitting**
  : List containing train-test split of inputs. Output types match
    input types (cudf inputs return cudf outputs, cupy inputs return
    cupy outputs, etc.)

### Examples

```pycon
>>> import cupy as cp
>>> from cuml.model_selection import train_test_split
>>> X = cp.arange(10).reshape((5, 2))
>>> y = cp.array([0, 0, 1, 1, 1])
>>> X_train, X_test, y_train, y_test = train_test_split(
...     X, y, test_size=0.2, random_state=42
... )
```

<!-- !! processed by numpydoc !! -->
