Bỏ phiếu

Ensemble Methods in Python

Román de las Heras

Data Scientist, Appodeal

Hỏi khán giả

hỏi-khán-giả.gif

Trí tuệ đám đông

  • Trí tuệ tập thể
  • Nhóm lớn >= Chuyên gia đơn lẻ
  • Giải quyết vấn đề
  • Ra quyết định
  • Đổi mới
  • Dự báo
Ensemble Methods in Python

Bỏ phiếu đa số

Thuộc tính

  • Bài toán phân loại
  • Bỏ phiếu đa số: Mode
  • Số bộ phân loại lẻ (≥3)

dự-bá-nhiều-mốt.png

Đặc điểm của đám đông khôn ngoan:

  • Đa dạng: thuật toán hoặc dữ liệu khác nhau
  • Độc lập, không tương quan
  • Tận dụng kiến thức riêng lẻ
  • Tổng hợp dự đoán cá nhân
Ensemble Methods in Python

Tổ hợp bỏ phiếu với scikit-learn

from sklearn.ensemble import VotingClassifier

clf_voting = VotingClassifier( estimators=[ ('label1', clf_1), ('label2', clf_2), ('labelN', clf_N)])

Đánh giá hiệu năng

# Get the accuracy score 
acc = accuracy_score(y_test, y_pred)
print("Accuracy: {:0.3f}".format(acc))
Accuracy: 0.938
# Create the individual models
clf_knn = KNeighborsClassifier(5)
clf_dt = DecisionTreeClassifier()
clf_lr = LogisticRegression()

# Create voting classifier clf_voting = VotingClassifier( estimators=[ ('knn', clf_knn), ('dt', clf_dt), ('lr', clf_lr)])
# Fit it to the training set and predict clf_voting.fit(X_train, y_train) y_pred = clf_voting.predict(X_test)
Ensemble Methods in Python

Hãy thử áp dụng!

Ensemble Methods in Python

Preparing Video For Download...