Trasformazioni, feature e target

Machine Learning per la finanza in Python

Nathan George

Data Science Professor

Creare feature e target

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 per la finanza in Python

prezzo e media mobile

Machine Learning per la finanza in Python

Medie mobili

Medie mobili:

  • usa n giorni passati per la media
  • valori comuni per n: 14, 50, 200
Machine Learning per la finanza in Python

prezzo e SMA

Machine Learning per la finanza in Python

grafico RSI e prezzo

Machine Learning per la finanza in Python

formula RSI

formula RS

Machine Learning per la finanza in Python

Calcolare SMA e 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 per la finanza in Python

Infine, le nostre feature

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 per la finanza in Python

Verificare le correlazioni

import seaborn as sns

corr = feature_target_df.corr()
sns.heatmap(corr, annot=True)
Machine Learning per la finanza in Python

grafico di correlazione tra feature e target

Machine Learning per la finanza in Python

Creiamo feature e target!

Machine Learning per la finanza in Python

Preparing Video For Download...