Tinh chỉnh siêu tham số trong Python
Alex Scriven
Data Scientist
Siêu tham số:

Tạo một random forest estimator đơn giản và in ra:
rf_clf = RandomForestClassifier() print(rf_clf)RandomForestClassifier(n_estimators='warn', criterion='gini', max_depth=None, max_features='auto', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, min_samples_leaf=1, min_samples_split=2, min_weight_fraction_leaf=0.0, n_jobs=None, oob_score=False, random_state=None, verbose=0,bootstrap=True, class_weight=None, warm_start=False)
Thêm thông tin: http://scikit-learn.org
Xét tham số n_estimators.
Kiểu dữ liệu & Giá trị mặc định:
n_estimators : integer, optional (default=10)
Định nghĩa:
Số cây trong rừng.
Đặt một số siêu tham số khi tạo estimator:
rf_clf = RandomForestClassifier(n_estimators=100, criterion='entropy')
print(rf_clf)
RandomForestClassifier(n_estimators=100, criterion='entropy',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_jobs=None,
oob_score=False, random_state=None, verbose=0,bootstrap=True,
class_weight=None, warm_start=False)
Tìm siêu tham số của Logistic Regression:
log_reg_clf = LogisticRegression()print(log_reg_clf) LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True, intercept_scaling=1, max_iter=100, multi_class='warn', n_jobs=None, penalty='l2', random_state=None, solver='warn', tol=0.0001, verbose=0, warm_start=False)
Ít siêu tham số cần tinh chỉnh hơn với thuật toán này!
Một số siêu tham số quan trọng hơn các tham số khác.
Một số sẽ không cải thiện hiệu năng mô hình:
Với random forest classifier:
n_jobsrandom_state verboseKhông phải siêu tham số nào cũng nên “huấn luyện”
Một số siêu tham số quan trọng:
n_estimators (giá trị cao)max_features (thử nhiều giá trị)max_depth & min_sample_leaf (quan trọng để tránh overfitting)criterionNhớ: chỉ là gợi ý
Một số nguồn để học:
Tinh chỉnh siêu tham số trong Python