Neural networks

Machine Learning voor finance in Python

Nathan George

Data Science Professor

GPU wet van Moore

Machine Learning voor finance in Python

Neural networks hebben potentie

Neurale netten hebben:

  • niet-lineariteit
  • variabele interacties
  • aanpasbaarheid
Machine Learning voor finance in Python

basisdiagram neuraal netwerk

Machine Learning voor finance in Python

netwerkdiagram met basiswiskunde

Machine Learning voor finance in Python

neuraal netwerk wiskunde

Machine Learning voor finance in Python

activatie neuraal netwerk diagram

Machine Learning voor finance in Python

activatiefunctie

Machine Learning voor finance in Python

verliesfunctie

Machine Learning voor finance in Python

forward pass

Machine Learning voor finance in Python

backwards pass

Machine Learning voor finance in Python

keras- en tensorflow-logo's

Machine Learning voor finance in Python

Een neuraal netwerk bouwen met keras

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
Machine Learning voor finance in Python

Een neuraal netwerk bouwen met 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'))
Machine Learning voor finance in Python

Het model fitten

model.compile(optimizer='adam', loss='mse')
history = model.fit(scaled_train_features, 
                    train_targets, 
                    epochs=50)
Machine Learning voor finance in Python
plt.plot(history.history['loss'])
plt.title('loss:' + str(round(history.history['loss'][-1], 6)))
plt.xlabel('epoch')
plt.ylabel('loss')
plt.show()

verlies-plot

Machine Learning voor finance in Python

Prestatie bekijken

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
Machine Learning voor finance in Python

Prestatie plotten

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

voorspellingen vs werkelijk

Machine Learning voor finance in Python

Bouw een neuraal netwerk!

Machine Learning voor finance in Python

Preparing Video For Download...