Veriyi ölçekleme ve KNN Regresyon

Python ile Finans için Machine Learning

Nathan George

Data Science Professor

özellik önemleri

Python ile Finans için Machine Learning

Özellik seçimi: hafta içlerini kaldır

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']
Python ile Finans için Machine Learning

Hafta içlerini kaldır

train_features = train_features.iloc[:, :-4]
test_features = test_features.iloc[:, :-4]
Python ile Finans için Machine Learning

2B özellik grafiği

Python ile Finans için Machine Learning

bilinmeyen için knn tahmini

Python ile Finans için Machine Learning

2 en yakın noktayla knn tahmini

Python ile Finans için Machine Learning

minowski mesafesi

Python ile Finans için Machine Learning

büyük ve küçük özellik

Python ile Finans için Machine Learning

Ölçekleme seçenekleri

Ölçekleme seçenekleri:

  • min-max
  • standardizasyon
  • medyan-MAD
  • keyfi bir fonksiyona eşle (örn. sigmoid, tanh)
Python ile Finans için Machine Learning

ölçekleme öncesi ve sonrası 2B özellik grafikleri

Python ile Finans için Machine Learning

sklearn'in scale'ı

from sklearn.preprocessing import scale

sc = scale()
scaled_train_features = sc.fit_transform(train_features)
scaled_test_features = sc.transform(test_features)
Python ile Finans için Machine Learning

standardizasyon öncesi ve sonrası

Python ile Finans için Machine Learning

Alt grafikler oluşturma

# 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()
Python ile Finans için Machine Learning

Veriyi ölçekle ve KNN kullan!

Python ile Finans için Machine Learning

Preparing Video For Download...