决策函数中的特征系数。随机森林

ena*_*ena 3 python machine-learning random-forest scikit-learn cross-validation

我该如何获取逻辑回归中model.coef_RandomForest()等特征的系数?

model = GridSearchCV(estimator=classifier,  param_grid=grid_param,
                     scoring='roc_auc',
                     cv=5,
                     n_jobs=-1) 
best_model= model.fit(X_train, y_train)
best_model.feature_importances_
Run Code Online (Sandbox Code Playgroud)

Sup*_*dar 7

Random forest是 的系综decision trees,它不是线性模型。Sklearn 提供了用于训练随机森林分类器或回归器的各个特征的重要性。可以按如下方式访问它,并返回一个总和为 1 的小数数组。

model.feature_importances_
Run Code Online (Sandbox Code Playgroud)

如果您想结合功能名称查看此内容,则可以使用zip(<feature names>, model.feature_importances_),并将其转换为list