ニューラルネットワーク

Python による金融のための Machine Learning

Nathan George

Data Science Professor

GPUのムーアの法則

Python による金融のための Machine Learning

ニューラルネットワークの可能性

ニューラルネットの特徴:

  • 非線形性
  • 変数間の相互作用
  • カスタマイズ性
Python による金融のための Machine Learning

基本的なニューラルネットワークの図

Python による金融のための Machine Learning

基本的な数式付きネットワーク図

Python による金融のための Machine Learning

ニューラルネットワークの数式

Python による金融のための Machine Learning

ニューラルネットワークの活性化ダイアグラム

Python による金融のための Machine Learning

活性化関数

Python による金融のための Machine Learning

損失関数

Python による金融のための Machine Learning

順伝播

Python による金融のための Machine Learning

逆伝播

Python による金融のための Machine Learning

kerasとtensorflowのロゴ

Python による金融のための Machine Learning

kerasでニューラルネットを実装する

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
Python による金融のための Machine Learning

kerasでニューラルネットを実装する

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense


model = Sequential()
model.add(Dense(50, input_dim=scaled_train_features.shape[1], activation='relu')) model.add(Dense(10, activation='relu')) model.add(Dense(1, activation='linear'))
Python による金融のための Machine Learning

モデルの訓練

model.compile(optimizer='adam', loss='mse')
history = model.fit(scaled_train_features, 
                    train_targets, 
                    epochs=50)
Python による金融のための Machine Learning
plt.plot(history.history['loss'])
plt.title('loss:' + str(round(history.history['loss'][-1], 6)))
plt.xlabel('epoch')
plt.ylabel('loss')
plt.show()

損失のプロット

Python による金融のための Machine Learning

性能の評価

from sklearn.metrics import r2_score

# calculate R^2 score
train_preds = model.predict(scaled_train_features)
print(r2_score(train_targets, train_preds))
0.4771387560719418
Python による金融のための Machine Learning

性能のプロット

# plot predictions vs actual
plt.scatter(train_preds, train_targets)
plt.xlabel('predictions')
plt.ylabel('actual')
plt.show()

予測値と実測値

Python による金融のための Machine Learning

ニューラルネットを作成しましょう!

Python による金融のための Machine Learning

Preparing Video For Download...