簡體   English   中英

使用Python的Databricks中的XGBoost

[英]XGBoost in Databricks with Python

因此,最近我一直在研究Mlib Databricks集群,並發現根據文檔XGBoost可用於我的集群版本(5.1)。 該集群正在運行Python 2。

我感到XGBoost4J僅適用於Scala和Java。 所以我的問題是:如何在不丟失分發功能的情況下將xgboost模塊導入此環境?

我的代碼示例如下

from pyspark.ml import Pipeline
from pyspark.ml.feature import StringIndexer
from pyspark.ml.feature import VectorAssembler
import xgboost as xgb # Throws error because module is not installed and it should

# Transform class to classIndex to make xgboost happy
stringIndexer = StringIndexer(inputCol="species", outputCol="species_index").fit(newInput)
labelTransformed = stringIndexer.transform(newInput).drop("species")

# Compose feature columns as vectors
vectorCols = ["sepal_length", "sepal_width", "petal_length", "petal_width", "species_index"]
vectorAssembler = VectorAssembler(inputCols=vectorCols, outputCol="features")
xgbInput = vectorAssembler.transform(labelTransformed).select("features", "species_index")

您可以嘗試使用spark-sklearn分發xgboost的python或scikit-learn版本,但是該分發與xgboost4j分發不同。 我聽說databricks上的xgboost4j的pyspark API即將推出,請繼續關注。

順便說一下,相關的拉取請求可以在這里找到

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM