Data transforms, features, and targets

Machine Learning para finanzas con Python

Nathan George

Data Science Professor

Making features and targets

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 para finanzas con Python

price and moving average

Machine Learning para finanzas con Python

Moving averages

Moving averages:

  • use n past days to get average
  • common values for n: 14, 50, 200
Machine Learning para finanzas con Python

price and sma

Machine Learning para finanzas con Python

RSI and price plot

Machine Learning para finanzas con Python

RSI equation

RS equation

Machine Learning para finanzas con Python

Calculating SMA and 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 para finanzas con Python

Finally, our features

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 para finanzas con Python

Check correlations

import seaborn as sns

corr = feature_target_df.corr()
sns.heatmap(corr, annot=True)
Machine Learning para finanzas con Python

feature and target correlation plot

Machine Learning para finanzas con Python

Let's create features and targets!

Machine Learning para finanzas con Python

Preparing Video For Download...