Özellik önemleri ve gradient boosting

Python ile Finans için Machine Learning

Nathan George

Data Science Professor

hafta günü ayrımı

Python ile Finans için Machine Learning

200 günlük SMA ayrımı

Python ile Finans için Machine Learning

Özellik önemlerini çıkarma

from sklearn.ensemble import RandomForestRegressor

random_forest = RandomForestRegressor()
random_forest.fit(train_features, train_targets)

feature_importances = random_forest.feature_importances_

print(feature_importances)
[0.07586547 0.10697602 0.12215955 0.23969227 0.29010304 0.0314028
 0.11977058 0.00276721 0.00246329 0.0026431  0.00615667]
Python ile Finans için Machine Learning

Sıralama ve görselleştirme

# rastgele orman modelinden özellik önemleri
importances = random_forest.feature_importances_

# en büyükten en küçüğe özellik önemlerinin indeksleri
sorted_index = np.argsort(importances)[::-1]

x = range(len(importances)) # eksen etiketlerini oluştur labels = np.array(feature_names)[sorted_index] plt.bar(x, importances[sorted_index], tick_label=labels) # etiketleri dikey döndür plt.xticks(rotation=90) plt.show()
Python ile Finans için Machine Learning

özellik önem grafiği

Python ile Finans için Machine Learning

Doğrusal modeller vs gradient boosting

Python ile Finans için Machine Learning

boosting diyagramı

Python ile Finans için Machine Learning

Boosted modeller

Mevcut boosted modeller:

  • Gradient boosting
  • Adaboost
Python ile Finans için Machine Learning

Bir gradient boosting modeli eğitme

from sklearn.ensemble import GradientBoostingRegressor

gbr = GradientBoostingRegressor(max_features=4,
                                learning_rate=0.01,
                                n_estimators=200,
                                subsample=0.6,
                                random_state=42)

gbr.fit(train_features, train_targets)
Python ile Finans için Machine Learning

Boost zamanı!

Python ile Finans için Machine Learning

Preparing Video For Download...