การแปลงข้อมูล, ฟีเจอร์, และเป้าหมาย

Machine Learning สำหรับการเงินด้วย Python

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
Machine Learning สำหรับการเงินด้วย Python

ราคาและค่าเฉลี่ยเคลื่อนที่

Machine Learning สำหรับการเงินด้วย Python

ค่าเฉลี่ยเคลื่อนที่

ค่าเฉลี่ยเคลื่อนที่:

  • ใช้ข้อมูล n วันย้อนหลังเพื่อคำนวณค่าเฉลี่ย
  • ค่า n ที่นิยมใช้: 14, 50, 200
Machine Learning สำหรับการเงินด้วย Python

ราคาและ SMA

Machine Learning สำหรับการเงินด้วย Python

กราฟ RSI และราคา

Machine Learning สำหรับการเงินด้วย Python

สมการ RSI

สมการ RS

Machine Learning สำหรับการเงินด้วย Python

การคำนวณ 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)
Machine Learning สำหรับการเงินด้วย Python

ฟีเจอร์ที่ได้

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']
Machine Learning สำหรับการเงินด้วย Python

ตรวจสอบความสัมพันธ์

import seaborn as sns

corr = feature_target_df.corr()
sns.heatmap(corr, annot=True)
Machine Learning สำหรับการเงินด้วย Python

กราฟความสัมพันธ์ระหว่างฟีเจอร์และเป้าหมาย

Machine Learning สำหรับการเงินด้วย Python

มาสร้างฟีเจอร์และเป้าหมายกัน!

Machine Learning สำหรับการเงินด้วย Python

Preparing Video For Download...