Neuronové sítě

Machine Learning for Finance in Python

Nathan George

Data Science Professor

Moorův zákon pro GPU

Machine Learning for Finance in Python

Potenciál neuronových sítí

Neuronové sítě nabízejí:

  • nelinearitu
  • interakce proměnných
  • přizpůsobitelnost
Machine Learning for Finance in Python

diagram základní neuronové sítě

Machine Learning for Finance in Python

diagram sítě se základní matematikou

Machine Learning for Finance in Python

matematika neuronové sítě

Machine Learning for Finance in Python

diagram aktivací neuronové sítě

Machine Learning for Finance in Python

aktivační funkce

Machine Learning for Finance in Python

ztrátová funkce

Machine Learning for Finance in Python

dopředný průchod

Machine Learning for Finance in Python

zpětný průchod

Machine Learning for Finance in Python

loga Keras a TensorFlow

Machine Learning for Finance in Python

Implementace neuronové sítě v Keras

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
Machine Learning for Finance in Python

Implementace neuronové sítě v 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 for Finance in Python

Trénování modelu

model.compile(optimizer='adam', loss='mse')
history = model.fit(scaled_train_features, 
                    train_targets, 
                    epochs=50)
Machine Learning for 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()

graf ztrátové funkce

Machine Learning for Finance in Python

Vyhodnocení výkonu

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 for Finance in Python

Vizualizace výkonu

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

predikce vs skutečné hodnoty

Machine Learning for Finance in Python

Vytvořte neuronovou síť!

Machine Learning for Finance in Python

Preparing Video For Download...