Holdout set’lerin sorunları

Python'da Model Doğrulama

Kasey Jones

Data Scientist

Doğrulamaya geçiş

Geleneksel eğitim-test bölmesi, verinin çoğunu eğitim için, küçük bir kısmını yalnızca test için kullanır.

X_train, X_val, y_train, y_val =
    train_test_split(X, y,
    test_size=0.2)

rf = RandomForestRegressor()

rf.fit(X_train, y_train)

out_of_sample = rf.predict(X_test) print(mae(y_test, out_of_sample))
10.24
Python'da Model Doğrulama

Geleneksel eğitim bölmeleri

cd = pd.read_csv("candy-data.csv")
s1 = cd.sample(60, random_state=1111)
s2 = cd.sample(60, random_state=1112)

Çakışan şekerler:

print(len([i for i in s1.index if i in s2.index]))
39
Python'da Model Doğrulama

Geleneksel eğitim bölmeleri

Çikolatalı şekerler:

print(s1.chocolate.value_counts()[0])
print(s2.chocolate.value_counts()[0])
34
30
Python'da Model Doğrulama

Bölme önemlidir

Örnek 1 test hatası

print('Test hatası: {0:.2f}'.format(mae(s1_y_test, rfr.predict(s1_X_test))))
10.32

Örnek 2 test hatası

print('Test hatası: {0:.2f}'.format(mae(s2_y_test, rfr.predict(s2_X_test))))
11.56
Python'da Model Doğrulama

Eğitim, doğrulama, test

X_temp, X_val, y_temp, y_val = train_test_split(..., random_state=1111)
X_train, X_test, y_train, y_test = train_test_split(..., random_state=1111)

rfr = RandomForestRegressor(n_estimators=25, random_state=1111, max_features=4)
rfr.fit(X_train, y_train)

print('Doğrulama hatası: {0:.2f}'.format(mae(y_test, rfr.predict(X_test))))
9.18
print('Test hatası: {0:.2f}'.format(mae(y_val, rfr.predict(X_val))))
8.98
Python'da Model Doğrulama

2. tur

X_temp, X_val, y_temp, y_val = train_test_split(..., random_state=1171)
X_train, X_test, y_train, y_test = train_test_split(..., random_state=1171)

rfr = RandomForestRegressor(n_estimators=25, random_state=1111, max_features=4)
rfr.fit(X_train, y_train)

print('Doğrulama hatası: {0:.2f}'.format(mae(y_test, rfr.predict(X_test))))
8.73
print('Test hatası: {0:.2f}'.format(mae(y_val, rfr.predict(X_val))))
10.91
Python'da Model Doğrulama

Holdout set alıştırmaları

Python'da Model Doğrulama

Preparing Video For Download...