Tầm quan trọng của đặc trưng và gradient boosting

Machine Learning cho Tài chính bằng Python

Nathan George

Data Science Professor

chia theo ngày trong tuần

Machine Learning cho Tài chính bằng Python

chia theo SMA 200 ngày

Machine Learning cho Tài chính bằng Python

Trích xuất tầm quan trọng đặc trưng

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]
Machine Learning cho Tài chính bằng Python

Sắp xếp và vẽ biểu đồ

# feature importances from random forest model
importances = random_forest.feature_importances_

# index of greatest to least feature importances
sorted_index = np.argsort(importances)[::-1]

x = range(len(importances)) # create tick labels labels = np.array(feature_names)[sorted_index] plt.bar(x, importances[sorted_index], tick_label=labels) # rotate tick labels to vertical plt.xticks(rotation=90) plt.show()
Machine Learning cho Tài chính bằng Python

biểu đồ tầm quan trọng đặc trưng

Machine Learning cho Tài chính bằng Python

Mô hình tuyến tính vs gradient boosting

Machine Learning cho Tài chính bằng Python

sơ đồ boosting

Machine Learning cho Tài chính bằng Python

Mô hình Boosted

Các mô hình Boosted khả dụng:

  • Gradient boosting
  • Adaboost
Machine Learning cho Tài chính bằng Python

Huấn luyện mô hình gradient boosting

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)
Machine Learning cho Tài chính bằng Python

Boost lên nào!

Machine Learning cho Tài chính bằng Python

Preparing Video For Download...