過度擬合與集成

Python 金融 Machine Learning

Nathan George

Data Science Professor

overfitting

Python 金融 Machine Learning

簡化模型

limited net

Python 金融 Machine Learning

神經網路選項

對抗過度擬合的方法:

  • 減少節點數
  • 使用 L1/L2 正規化
  • Dropout
  • Autoencoder 架構
  • 早停
  • 對資料加入雜訊
  • 最大範數限制
  • 集成
Python 金融 Machine Learning

Dropout

dropout

Python 金融 Machine Learning

在 keras 中使用 Dropout

from keras.layers import Dense, Dropout

model = Sequential() model.add(Dense(500, input_dim=scaled_train_features.shape[1], activation='relu')) model.add(Dropout(0.5)) model.add(Dense(100, activation='relu')) model.add(Dense(1, activation='linear'))
Python 金融 Machine Learning

測試集比較

在 AMD(不含 dropout)的 R$^2$:

  • 訓練:0.91
  • 測試:-0.72

加入 dropout:

  • 訓練:0.46
  • 測試:-0.22
Python 金融 Machine Learning

集成

random forest

Python 金融 Machine Learning

實作集成

# 從 2 個神經網路模型產生預測
test_pred1 = model_1.predict(scaled_test_features)
test_pred2 = model_2.predict(scaled_test_features)

# 水平堆疊預測,並在列方向取平均 test_preds = np.mean(np.hstack((test_pred1, test_pred2)), axis=1)
Python 金融 Machine Learning

比較集成效果

模型 1 在測試集的 R$^2$:

  • -0.179

模型 2:

  • -0.148

集成(平均預測):

  • -0.146
Python 金融 Machine Learning

Dropout 與集成!

Python 金融 Machine Learning

Preparing Video For Download...