python - 使用带有间隔的 GridSearchCV

标签 python machine-learning data-science

当使用网格搜索在 python 中使用此函数 GridSearchCV() 进行分类器时,假设我们有一个参数区间来调整形式 1 到 100,我们如何能够指定它(1:100 不起作用)? p>

最佳答案

这是将参数传递给 GridSearchCV() 函数的方式:

pipeline = Pipeline([
    ('clf', OneVsRestClassifier(SVC(), n_jobs=1)),
])

parameters = [

    {'clf__estimator__kernel': ['rbf'],
     'clf__estimator__gamma': [1e-3, 1e-4],
     'clf__estimator__C': [1, 10]
    },

    {'clf__estimator__kernel': ['poly'],
     'clf__estimator__C': [1, 10]
    }
     ]

grid_search_tune = GridSearchCV(pipeline, parameters, cv=2, n_jobs=3, verbose=10)

关于python - 使用带有间隔的 GridSearchCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47961811/

相关文章:

python - 使用 Selenium Webdriver 和 FireFox 时出错

python - 如何将 C++ python 扩展导入到另一个目录中的模块中?

c# - 将时间序列模型与 PredictionEnginePool (ML.NET) 一起使用时 PredictionEngineBase 中出现异常

python - 根据不同列中的另外 2 个值求和一列的值

python - 是否可以在 Folium 中绘制路径?

python - 使用 python pysftp 包,出现 "SSHException: Bad host key from server"错误

Python 如何获取特定导数点的值?

python - Dataframe 上的 Pandas 条件返回 TypeError : '>' not supported between instances of 'str' and 'int'

python - 具有交叉熵损失的 Softmax 激活导致两个类别的输出分别准确地收敛于 0 和 1

python - 从金字塔导入 auto_arima 时出错