Cross Validation

wandajeong·2021년 12월 26일
0

Machine Learning

목록 보기
6/15
post-custom-banner

cross_val_score

from sklearn.model_selection import cross_val_score

scores = cross_val_score(model, X_train, y_train, scoring='accuracy') #default cv=5

scores = cross_val_score(model, X_train, y_train, cv=30)

LOOCV(Leave-One-Out Cross-Validation)

  • 데이터가 매우 적을때 사용
# LOOCV is very time-consuming => useful in small data

from sklearn.model_selection import LeaveOneOut

scores = cross_val_score(model, X_train, y_train, cv=LeaveOneOut())
scores.mean()

Shuffle-Split Cross-Validation

shuffle_split

from sklearn.model_selection import ShuffleSplit

sscv = ShuffleSplit(test_size=.5, train_size=.4, n_splits=10)
scores = cross_val_score(model, X_train, y_train, cv=sscv)
scores.mean()
scores
profile
ML/DL swimmer
post-custom-banner

0개의 댓글