【问题标题】:Can RandomizedSearchCV output feature importance based on the best model?RandomizedSearchCV 能否根据最佳模型输出特征重要性?
【发布时间】:2018-12-09 02:45:57
【问题描述】:

使用 RandomizedSearchCV 找到最佳超参数后,有没有办法找到以下输出? 1.将最佳模型保存为对象 2.输出特征重要性

gbm = GradientBoostingClassifier()
rand = RandomizedSearchCV(gbm, param_distributions=param_dist, cv=10, 
scoring='roc_auc', n_iter=10, random_state=5)
rand.fit(X_train, y_train_num)

【问题讨论】:

    标签: python-3.x


    【解决方案1】:

    使用 best_params_ 参数并将其保存到字典中。从字典中重新训练模型并通过键调用值。

    top_params = rand.best_params_
    gbm_model = GradientBoostingClassifier(learning_rate=top_params['learning_rate'], max_depth=top_params["max_depth"], ...)
    gbm_model.fit(X_train, y_train_num)
    gbm_model.feature_importances_
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-21
      • 2021-04-15
      • 2018-10-17
      • 2021-11-07
      • 2018-11-28
      • 2019-01-09
      • 2014-02-12
      • 2022-08-05
      相关资源
      最近更新 更多