데이터 변환, 피처 및 타깃

Python으로 배우는 금융 분야 Machine Learning

Nathan George

Data Science Professor

피처와 타깃 생성

features = amd_df[['10d_close_pct', 'Adj_Volume']]

targets = amd_df['10d_future_close_pct']
print(type(features))
pandas.core.series.DataFrame
print(type(targets))
pandas.core.series.Series
Python으로 배우는 금융 분야 Machine Learning

가격과 이동 평균

Python으로 배우는 금융 분야 Machine Learning

이동 평균

이동 평균:

  • 과거 n일의 평균 사용
  • n의 일반적인 값: 14, 50, 200
Python으로 배우는 금융 분야 Machine Learning

가격과 단순 이동 평균

Python으로 배우는 금융 분야 Machine Learning

RSI와 가격 플롯

Python으로 배우는 금융 분야 Machine Learning

RSI 수식

RS 수식

Python으로 배우는 금융 분야 Machine Learning

SMA와 RSI 계산

import talib

amd_df['ma200'] = talib.SMA(amd_df['Adj_Close'].values, timeperiod=200)
amd_df['rsi200'] = talib.RSI(amd_df['Adj_Close'].values, timeperiod=200)
Python으로 배우는 금융 분야 Machine Learning

최종 피처 정의

feature_names = ['10d_close_pct', 'ma200', 'rsi200']
features = amd_df[feature_names]
targets = amd_df['10d_future_close_pct']

feature_target_df = amd_df[feature_names + '10d_future_close_pct']
Python으로 배우는 금융 분야 Machine Learning

상관관계 확인

import seaborn as sns

corr = feature_target_df.corr()
sns.heatmap(corr, annot=True)
Python으로 배우는 금융 분야 Machine Learning

피처와 타깃 상관관계 플롯

Python으로 배우는 금융 분야 Machine Learning

피처와 타깃을 직접 만들어 봅시다!

Python으로 배우는 금융 분야 Machine Learning

Preparing Video For Download...