python - Spark_sklearn GridSearchCV __init__ 因参数错误而失败

标签 python apache-spark machine-learning scikit-learn

我尝试使用spark_sklearn.GridSearchCV,但出现init参数错误。

TypeError: __init__() takes at least 4 arguments (4 given)

这是代码:

from spark_sklearn import GridSearchCV

gsearch2 = GridSearchCV(estimator=ensemble.GradientBoostingRegressor(**params), param_grid=param_test2, n_jobs=1)

如果我给GridSearchCV更多的参数,比如添加cv=5,那么错误就会变成

TypeError: __init__() takes at least 4 arguments (5 given)

有什么建议吗?

谢谢。

最佳答案

GridSearchCV.__init__ 需要 3 obligatory arguments :

  • sc - SparkContext
  • 估计器
  • param_grid

您忘记了SparkContext:

GridSearchCV(
    sc=SparkContext.getOrCreate(),
    estimator=ensemble.GradientBoostingRegressor(**params), 
    param_grid=param_test2, n_jobs=1)

关于python - Spark_sklearn GridSearchCV __init__ 因参数错误而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47723547/

相关文章:

python - 产生大量随机变量

azure - Databricks 连接 : can't connect to remote cluster on azure, 命令: 'databricks-connect test' 停止

apache-spark - Apache Spark 文本相似度

multithreading - 并行神经网络

Python self 复制类

python - 如何将新的键值对添加到字典列表中?

python - 当我将 numpy 数组转换为 Dataframe 时,它​​将值更新为 Nan

python - 在标准化训练数据后使用 sklearn 预测新数据

python - 如何使用 Products.csvreplicata 1.1.7 和 Products.PressRoom 在 Plone 4.1 中导出 PressContacts

linux - 如何使用 linux HDInsight 更改 zeppelin 的资源