신경망

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...