Python 的模型驗證
Kasey Jones
Data Scientist

| 資料集 | 定義 |
|---|---|
| Train | 用於擬合模型的資料樣本 |
| Test(保留樣本) | 用於評估模型效能的資料樣本 |
比例範例
import pandas as pd
tic_tac_toe = pd.read_csv("tic-tac-toe.csv")
X = pd.get_dummies(tic_tac_toe.iloc[:,0:9])
y = tic_tac_toe.iloc[:, 9]
涵蓋虛擬變數的 Python 課程:
X_train, X_test, y_train, y_test =\
train_test_split(X, y, test_size=0.2, random_state=1111)
參數:
test_sizetrain_sizerandom_state當要測試不同的模型參數時該怎麼做?

X_temp, X_test, y_temp, y_test =\
train_test_split(X, y, test_size=0.2, random_state=1111)
X_train, X_val, y_train, y_val =\
train_test_split(X_temp, y_temp, test_size=0.25, random_state=11111)
Python 的模型驗證