Xác thực cục bộ

Chinh phục cuộc thi Kaggle bằng Python

Yauhen Babakhin

Kaggle Grandmaster

Động lực

ví dụ overfitting với bảng xếp hạng Public và Private

Chinh phục cuộc thi Kaggle bằng Python

Tập holdout

sơ đồ tập holdout

Chinh phục cuộc thi Kaggle bằng Python

Tập holdout

sơ đồ tập holdout

Chinh phục cuộc thi Kaggle bằng Python

Tập holdout

sơ đồ tập holdout

Chinh phục cuộc thi Kaggle bằng Python

K-fold cross-validation

 

chia dữ liệu train thành bốn fold

Chinh phục cuộc thi Kaggle bằng Python

K-fold cross-validation

 

sơ đồ k-fold cross-validation

Chinh phục cuộc thi Kaggle bằng Python

K-fold cross-validation

# Import KFold
from sklearn.model_selection import KFold
# Tạo đối tượng KFold
kf = KFold(n_splits=5, shuffle=True, random_state=123)
# Lặp qua từng lần chia cross-validation
for train_index, test_index in kf.split(train):

# Lấy dữ liệu train và test cho lần chia tương ứng cv_train, cv_test = train.iloc[train_index], train.iloc[test_index]
Chinh phục cuộc thi Kaggle bằng Python

Stratified K-fold

  sơ đồ stratified k-fold cross-validation

Chinh phục cuộc thi Kaggle bằng Python

Stratified K-fold

# Import StratifiedKFold
from sklearn.model_selection import StratifiedKFold

# Tạo đối tượng StratifiedKFold str_kf = StratifiedKFold(n_splits=5, shuffle=True, random_state=123)
# Lặp qua từng lần chia cross-validation for train_index, test_index in str_kf.split(train, train['target']): cv_train, cv_test = train.iloc[train_index], train.iloc[test_index]
Chinh phục cuộc thi Kaggle bằng Python

Hãy luyện tập!

Chinh phục cuộc thi Kaggle bằng Python

Preparing Video For Download...