반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

sklearn.model_selection.train_test_split 본문

[AI]/python.sklearn

sklearn.model_selection.train_test_split

givemebro 2020. 4. 8. 12:47
반응형
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(iris.data,iris.target,shuffle=False)
# shuffle=False : 섞지 않겠다
# 기본 75% / 25%
np.bincount(y_test)
array([ 0,  0, 38], dtype=int64)

 

 

from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(iris.data,iris.target,shuffle=True)
# shuffle=True : 섞겠다
# 기본 75% / 25%
np.bincount(y_test)
array([11, 12, 15], dtype=int64)

 

X_train,X_test,y_train,y_test=train_test_split(iris.data,iris.target,shuffle=True,random_state=1)
# random_state=1 : 씨드값
np.bincount(y_test)
array([13, 16,  9], dtype=int64)

 

X_train,X_test,y_train,y_test=train_test_split(iris.data,iris.target,test_size=0.2,shuffle=True)
# test_size=20 : 테스트 데이터의 갯수를 20개로!
# test_size=0.2 : 테스트 데이터의 비율을 20%로!
np.bincount(y_test)
array([6, 6, 8], dtype=int64)
반응형

'[AI] > python.sklearn' 카테고리의 다른 글

sklearn.knn.KNeiborsClassifier(K값 변화에 따른 결과 관찰)  (0) 2020.04.09
sklearn.mglearn 사용  (0) 2020.04.09
sklearn.mglearn(install)  (0) 2020.04.09
machine learning.분류  (0) 2020.04.08
sklearn.iris data 불러오기  (0) 2020.04.08
sklearn.오류값 찾기  (0) 2020.04.08
sklearn.수치근사법  (0) 2020.04.08
sklearn.coef/intercept  (0) 2020.04.07
Comments