sklearn.model_selection.GridSearchCV 如何获取所有 .best_params_

svc_pipeline = make_pipeline(    StandardScaler(), SVC(random_state=1))pipe_svc_bag = BaggingClassifier(    base_estimator=svc_pipeline, n_estimators=10, bootstrap=True, random_state=1)param_grid = [    {'base_estimator__svc__kernel': ['linear', 'poly', 'rbf', 'sigmoid']},    {'base_estimator__svc__C': np.linspace(0.1, 2, 20)}]svc_bag_grid = GridSearchCV(    estimator=pipe_svc_bag, param_grid=param_grid, cv=10)svc_bag_grid.fit(X, y)print(svc_bag_grid.best_params_)

我在 param_grid 中指定了两个参数,当我调用 svc_bag_grid.best_params_ 时,它只返回 {'base_estimator__svc__kernel': 'linear'},但我也想知道我在 param_grid 中为 SVC() 指定的最佳 C 值。


回答:

param_grid 需要是一个字典,每个参数是其中的一个元素。而不是像你那样的一系列字典…

param_grid = {'base_estimator__svc__C': np.linspace(0.1, 2, 20),    'base_estimator__svc__kernel': ['linear', 'poly', 'rbf', 'sigmoid']}

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注