# 3.7.8.4. renom.utility.preprocess.train_test_split package ¶

class ``` TrainTestSplit ``` ( x , y=None , test_size=None )

 パラメータ: x ( ndarray ) – 分割するデータもしくはラベルデータ y ( default is None ) ( ndarray ) – 分割するデータもしくはラベルデータ test_size ( default is 0.25 ) ( float_or_int ) – テストデータのサイズ。割合もしくは大きさ
```>>> from utility.preprocess import TrainTestSplit
>>> import numpy as np
>>> x = np.arange(12).reshape(6,2)
>>> x
array([[ 0,  1],
[ 2,  3],
[ 4,  5],
[ 6,  7],
[ 8,  9],
[10, 11]])
>>> y = ['zero', '1st', '2nd', '3rd', '4th', '5th']
>>> hoge = TrainTestSplit(x, y, test_size = 0.3)
>>> x_train, x_test, y_train, y_test = hoge.transform()
>>> print x_train
[[ 2  3]
[10 11]
[ 4  5]
[ 8  9]]
>>> print x_test
[[6 7]
[0 1]]
>>> print y_train
['1st' '5th' '2nd' '4th']
>>> print y_test
['3rd' 'zero']
```
``` transform ``` ( )

 Return tuple: 学習・テストデータを含むタプル
```>>> from utility.preprocess import TrainTestSplit
>>> import numpy as np
>>> x = np.arange(12).reshape(6,2)
>>> x
array([[ 0,  1],
[ 2,  3],
[ 4,  5],
[ 6,  7],
[ 8,  9],
[10, 11]])
>>> y = ['zero', '1st', '2nd', '3rd', '4th', '5th']
>>> hoge = TrainTestSplit(x, y, test_size = 0.3)
>>> x_train, x_test, y_train, y_test = hoge.transform()
>>> print x_train
[[ 2  3]
[10 11]
[ 4  5]
[ 8  9]]
>>> print x_test
[[6 7]
[0 1]]
>>> print y_train
['1st' '5th' '2nd' '4th']
>>> print y_test
['3rd' 'zero']
```
``` train_test_split ``` ( x , y=None , test_size=None )

 パラメータ: x ( ndarray ) – 分割するデータもしくはラベルデータ y ( default is None ) ( ndarray ) – 分割するデータもしくはラベルデータ test_size ( default is 0.25 ) ( float_or_int ) – テストデータのサイズ。割合もしくは大きさ 学習・テストデータを含むタプル
```>>> from utility.preprocess import train_test_split
>>> import numpy as np
>>> x = np.arange(12).reshape(6,2)
>>> x
array([[ 0,  1],
[ 2,  3],
[ 4,  5],
[ 6,  7],
[ 8,  9],
[10, 11]])
>>> y = ['zero', '1st', '2nd', '3rd', '4th', '5th']
>>> x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.3)
>>> print x_train
[[ 2  3]
[10 11]
[ 4  5]
[ 8  9]]
>>> print x_test
[[6 7]
[0 1]]
>>> print y_train
['1st' '5th' '2nd' '4th']
>>> print y_test
['3rd' 'zero']
```