본문 바로가기
개발/python

Kaggle - London Bike Sharing (3): 데이터셋 split

by freshplay 2023. 10. 3.
# y에는 이용객 수를, x에는 그 외 값들을 넣는다. 
# timestamp 정보는 year/hour 등으로 나뉘어 들어가있으므로 df_x에서는 'timestamp'와 'cnt'를 제거
df_y = df_out['cnt']
df_x = df_out.drop['timestamp','cnt'],axis=1) # 열 기준으로 'timestamp', 'cnt' 값에 해당하는 데이터 drop




from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(df_x, df_y, random_state=66, test_size=0.3, shuffle=False)
'''
random_state : 데이터를 랜덤으로 분리할 것인지 여부, 어떤 값이든 값이 들어가면 random_state 안함
shuffle : 분리된 데이터 내에서 순서를 섞을 것인지 여부, 이 데이터는 시계열 데이터이기 때문에 False
'''

>> 다음과 같이 데이터가 분리된다.