我想更新我的 pyspark 代码。在pyspark中,它必须将基础模型放入管道中,即办公室演示 http://spark.apache.org/docs/latest/ml-pipeline.html管道使用逻辑回归作为基本模型。但是,似乎无法在管道 API 中使用 XGboost 模型。我怎样才能像这样使用pyspark
from xgboost import XGBClassifier
...
model = XGBClassifier()
model.fit(X_train, y_train)
pipeline = Pipeline(stages=[..., model, ...])
...
使用 pipeline api 很方便,有人可以给一些建议吗?谢谢。
Apache Spark ML 中没有 XGBoost 分类器(截至版本 2.3)。此处列出了可用型号:https://spark.apache.org/docs/2.3.0/ml-classification-regression.html https://spark.apache.org/docs/2.3.0/ml-classification-regression.html
如果你想使用 XGBoost,你应该在没有 pyspark 的情况下使用(将你的 Spark 数据帧转换为 pandas 数据帧).toPandas()
)或使用另一种算法(https://spark.apache.org/docs/2.3.0/api/python/pyspark.ml.html#module-pyspark.ml.classification https://spark.apache.org/docs/2.3.0/api/python/pyspark.ml.html#module-pyspark.ml.classification).
但如果您确实想将 XGBoost 与 pyspark 一起使用,则必须深入研究 pyspark 自己实现分布式 XGBoost。这是他们这样做的一篇文章:http://dmlc.ml/2016/10/26/a-full-integration-of-xgboost-and-spark.html http://dmlc.ml/2016/10/26/a-full-integration-of-xgboost-and-spark.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)