การสร้างฟีเจอร์

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

Nathan George

Data Science Professor

ความสัมพันธ์แบบไม่เชิงเส้นของฟีเจอร์

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

ข้อจำกัดของโมเดลเชิงเส้น

# add non-linear interaction term for a linear model
SMAxRSI = amd_df['14-day SMA'] * amd_df['14-day RSI']

โมเดลบางประเภทที่ไม่จำเป็นต้องสร้าง interaction feature ด้วยตนเอง:

โมเดลแบบ decision tree

  • Random forests
  • Gradient boosting

ประเภทอื่น

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

ปริมาณการซื้อขาย vs การเปลี่ยนแปลงราคา

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

ข้อมูลราคาและปริมาณการซื้อขาย

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

ฟีเจอร์จากปริมาณการซื้อขาย

amd_df['Adj_Volume_1d_change'] = amd_df['Adj_Volume'].pct_change()

one_day_change = amd_df['Adj_Volume_1d_change'].values amd_df['Adj_Volume_1d_change_SMA'] = talib.SMA(one_day_change, timeperiod=10)
Machine Learning สำหรับการเงินด้วย Python

การสร้างฟีเจอร์จาก Datetime

แผนภาพ datetime พร้อมลูกศรชี้ไปยังวันในสัปดาห์ เดือน และปี

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

การดึงข้อมูลวันในสัปดาห์

print(amd_df.index.dayofweek)
Int64Index([2, 3, 4, 0, 1, 2, 3, 4, 0, 1,
            ...
            1, 2, 3, 4, 0, 1, 2, 3, 4, 0],
           dtype='int64', name='Date', length=4807)
Machine Learning สำหรับการเงินด้วย Python

Dummy variables

days_of_week = pd.get_dummies(amd_df.index.dayofweek,
                                prefix='weekday',
                                drop_first=True)

print(days_of_week.head())
            weekday_1  weekday_2  weekday_3  weekday_4
Date
2018-04-10          1          0          0          0
2018-04-11          0          1          0          0
2018-04-12          0          0          1          0
2018-04-13          0          0          0          1
2018-04-16          0          0          0          0
Machine Learning สำหรับการเงินด้วย Python

กราฟความสัมพันธ์ของฟีเจอร์ใหม่

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

มาสร้างฟีเจอร์กันเถอะ!

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

Preparing Video For Download...