Neural Networks

Machine Learning cho Tài chính bằng Python

Nathan George

Data Science Professor

Định luật Moore cho GPU

Machine Learning cho Tài chính bằng Python

Neural networks có nhiều tiềm năng

Neural net có:

  • phi tuyến tính
  • tương tác giữa biến
  • khả năng tùy biến
Machine Learning cho Tài chính bằng Python

sơ đồ neural net cơ bản

Machine Learning cho Tài chính bằng Python

sơ đồ mạng với toán cơ bản

Machine Learning cho Tài chính bằng Python

toán của neural net

Machine Learning cho Tài chính bằng Python

kích hoạt trong sơ đồ neural net

Machine Learning cho Tài chính bằng Python

hàm kích hoạt

Machine Learning cho Tài chính bằng Python

hàm mất mát

Machine Learning cho Tài chính bằng Python

lan truyền xuôi

Machine Learning cho Tài chính bằng Python

lan truyền ngược

Machine Learning cho Tài chính bằng Python

logo keras và tensorflow

Machine Learning cho Tài chính bằng Python

Xây neural net với keras

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
Machine Learning cho Tài chính bằng Python

Xây neural net với 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 cho Tài chính bằng Python

Huấn luyện mô hình

model.compile(optimizer='adam', loss='mse')
history = model.fit(scaled_train_features, 
                    train_targets, 
                    epochs=50)
Machine Learning cho Tài chính bằng Python
plt.plot(history.history['loss'])
plt.title('loss:' + str(round(history.history['loss'][-1], 6)))
plt.xlabel('epoch')
plt.ylabel('loss')
plt.show()

biểu đồ loss

Machine Learning cho Tài chính bằng Python

Kiểm tra hiệu năng

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 cho Tài chính bằng Python

Vẽ hiệu năng

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

dự đoán vs thực tế

Machine Learning cho Tài chính bằng Python

Tạo một neural net!

Machine Learning cho Tài chính bằng Python

Preparing Video For Download...