Data schalen en KNN-regressie

Machine Learning voor finance in Python

Nathan George

Data Science Professor

feature-importances

Machine Learning voor finance in Python

Featureselectie: weekdagen verwijderen

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

Weekdagen verwijderen

train_features = train_features.iloc[:, :-4]
test_features = test_features.iloc[:, :-4]
Machine Learning voor finance in Python

2D-featureplot

Machine Learning voor finance in Python

knn-voorspelling onbekend

Machine Learning voor finance in Python

knn-voorspelling met 2 dichtstbijzijnde punten

Machine Learning voor finance in Python

minowski-afstand

Machine Learning voor finance in Python

grote en kleine features

Machine Learning voor finance in Python

Schaalopties

Schaalopties:

  • min-max
  • standaardisatie
  • mediaan–MAD
  • mappen naar willekeurige functie (bv. sigmoid, tanh)
Machine Learning voor finance in Python

2D-featureplots voor en na schalen

Machine Learning voor finance in Python

sklearn: scale

from sklearn.preprocessing import scale

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

voor en na standaardisatie

Machine Learning voor finance in Python

Subplots maken

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

Schaal data en gebruik KNN!

Machine Learning voor finance in Python

Preparing Video For Download...