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

bro's coding

sklearn.model_selection.cross_val_score.KFold 본문

[AI]/python.sklearn

sklearn.model_selection.cross_val_score.KFold

givemebro 2020. 4. 24. 11:31
반응형
from sklearn.model_selection import KFold
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
from sklearn.datasets import load_iris

iris=load_iris()

kfold=KFold(3) # shuffle = False

 

 

from sklearn.model_selection import KFold

kfold=KFold(3) # shuffle = False
socres1=cross_val_score(LogisticRegression(),iris.data,iris.target,cv=kfold)

socres1

# array([0., 0., 0.])

shuffle을 적용하지 않아 세 조각으로 자른게 각 각의 꽃을 자른 모양이라 score이 0이 나온다.

 

kfold=KFold(3,shuffle = True) 
socres1=cross_val_score(LogisticRegression(),iris.data,iris.target,cv=kfold)

socres1

# array([0.98, 0.92, 0.98])

 

반응형
Comments