过拟合与集成

Python 金融机器学习

Nathan George

Data Science Professor

过拟合

Python 金融机器学习

简化模型

受限网络

Python 金融机器学习

神经网络选项

应对过拟合的选项:

  • 减少节点数
  • 使用 L1/L2 正则化
  • Dropout
  • 自编码器结构
  • 提前停止
  • 向数据添加噪声
  • 最大范数约束
  • 集成
Python 金融机器学习

Dropout

Dropout

Python 金融机器学习

在 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 金融机器学习

测试集对比

在 AMD 上的 R$^2$(无 dropout):

  • 训练:0.91
  • 测试:-0.72

使用 dropout:

  • 训练:0.46
  • 测试:-0.22
Python 金融机器学习

集成学习

随机森林

Python 金融机器学习

实现集成

# make predictions from 2 neural net models
test_pred1 = model_1.predict(scaled_test_features)
test_pred2 = model_2.predict(scaled_test_features)

# horizontally stack predictions and take the average across rows test_preds = np.mean(np.hstack((test_pred1, test_pred2)), axis=1)
Python 金融机器学习

比较集成效果

模型 1 在测试集上的 R$^2$:

  • -0.179

模型 2:

  • -0.148

集成(平均预测):

  • -0.146
Python 金融机器学习

Dropout 与集成!

Python 金融机器学习

Preparing Video For Download...