Features engineeren

Machine Learning voor finance in Python

Nathan George

Data Science Professor

niet-lineaire featurecorrelatie

Machine Learning voor finance in Python

Eén probleem met lineaire modellen

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

Sommige modellen vereisen geen handmatige interactie-features:

Beslisboom-gebaseerde modellen

  • Random forests
  • Gradient boosting

Overige

  • neural networks
Machine Learning voor finance in Python

volume vs prijsverandering

Machine Learning voor finance in Python

prijs en volume

Machine Learning voor finance in Python

Volumefeatures

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 voor finance in Python

Datetime feature engineering

grafiek van datetime met pijlen naar dag van week, maand, jaar

Machine Learning voor finance in Python

De weekdag extraheren

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 voor finance in Python

Dummies

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 voor finance in Python

correlatieplot van nieuwe features

Machine Learning voor finance in Python

Engineer wat features!

Machine Learning voor finance in Python

Preparing Video For Download...