train_test_split() - (3)
Data Analyst

빅데이터 관련 자료/Dacon

train_test_split() - (3)

carpe08 2021. 11. 22. 00:25
320x100
320x100

이번시간에는 train_test_split() 메소드의 test_size 파라미터와 shuffle 파라미터 에 대해 알아보겠습니다.

  • test_size: test data(validation data) 구성의 비율을 나타냅니다. train_size의 옵션과 반대 관계에 있는 옵션 값이며, 주로 test_size 파라미터를 지정 해줍니다. test_size = 0.2 로 지정 하면 전체 데이터 셋의 20%를 test(validation) 셋으로 지정하겠다는 의미입니다. default 값은 0.25 입니다.

 

  • shuffle: 데이터를 split 하기 이전에 섞을지 말지 여부에 대해 지정해주는 파라미터 입니다. default = True 입니다.
# 라이브러리 로딩

from sklearn.model_selection import train_test_split



#train_test_split() 메소드를 이용해 train/validation 데이터 나누기 

# test_size = 0.2로 지정하여 데이터 셋 split



x_train,x_valid, y_train, y_valid = train_test_split(train_x,train['category'],test_size = 0.2)



print('x_train 데이터 사이즈', x_train.shape)

print('x_valid 데이터 사이즈', x_valid.shape)

print('y_train 데이터 사이즈', y_train.shape)

print('y_valid 데이터 사이즈', y_valid.shape)





output :

x_train 데이터 사이즈 (28000, 697226)

x_valid 데이터 사이즈 (12000, 697226)

y_train 데이터 사이즈 (28000,)

y_valid 데이터 사이즈 (12000,)
320x100
320x100

'빅데이터 관련 자료 > Dacon' 카테고리의 다른 글

train_test_split / LGBM (1)  (0) 2021.11.24
train_test_split - (4)  (0) 2021.11.23
train_test_split() - (2)  (0) 2021.11.21
train_test_split - (1)  (0) 2021.11.20
TF-IDF(Term Frequency - Inverse Document Frequency) - (2)  (0) 2021.11.19