Škálování dat a KNN regrese

Machine Learning for Finance in Python

Nathan George

Data Science Professor

důležitost příznaků

Machine Learning for Finance in Python

Výběr příznaků: odstranění dnů týdne

print(feature_names)
['10d_close_pct',
 '14-day SMA',
 '14-day RSI',
 '200-day SMA',
 '200-day RSI',
 'Adj_Volume_1d_change',
 'Adj_Volume_1d_change_SMA',
 'weekday_1',
 'weekday_2',
 'weekday_3',
 'weekday_4']
print(feature_names[:-4])
['10d_close_pct',
 '14-day SMA',
 '14-day RSI',
 '200-day SMA',
 '200-day RSI',
 'Adj_Volume_1d_change',
 'Adj_Volume_1d_change_SMA']
Machine Learning for Finance in Python

Odstranění dnů týdne

train_features = train_features.iloc[:, :-4]
test_features = test_features.iloc[:, :-4]
Machine Learning for Finance in Python

2D graf příznaků

Machine Learning for Finance in Python

predikce KNN pro neznámý bod

Machine Learning for Finance in Python

predikce KNN se 2 nejbližšími body

Machine Learning for Finance in Python

Minkowského vzdálenost

Machine Learning for Finance in Python

velký a malý příznak

Machine Learning for Finance in Python

Možnosti škálování

Možnosti škálování:

  • min-max
  • standardizace
  • medián-MAD
  • mapování na libovolnou funkci (např. sigmoid, tanh)
Machine Learning for Finance in Python

2D grafy příznaků před a po škálování

Machine Learning for Finance in Python

Škálování v sklearn

from sklearn.preprocessing import scale

sc = scale()
scaled_train_features = sc.fit_transform(train_features)
scaled_test_features = sc.transform(test_features)
Machine Learning for Finance in Python

před a po standardizaci

Machine Learning for Finance in Python

Tvorba podgrafů

# create figure and list containing axes
f, ax = plt.subplots(nrows=2, ncols=1)

# plot histograms of before and after scaling train_features.iloc[:, 2].hist(ax=ax[0]) ax[1].hist(scaled_train_features[:, 2]) plt.show()
Machine Learning for Finance in Python

Škálujte data a použijte KNN!

Machine Learning for Finance in Python

Preparing Video For Download...