Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pySpark中随机森林的解释_Python_Apache Spark_Pyspark_Apache Spark Ml - Fatal编程技术网

Python pySpark中随机森林的解释

Python pySpark中随机森林的解释,python,apache-spark,pyspark,apache-spark-ml,Python,Apache Spark,Pyspark,Apache Spark Ml,大家晚上好 我试图找到一种解释火花中随机森林的方法。通过解释,我的意思是找出哪些变量在特定行中最具影响力 对于python,我曾经这样做: from treeinterpreter import treeinterpreter as ti prediction, bias, contributions = ti.predict(rfc, X) EconAttributes数组拥有我需要的所有信息,然后我可以对其进行操作以获得所需的结果。python中的spark有什么方法可以做到这一点吗?我想

大家晚上好

我试图找到一种解释火花中随机森林的方法。通过解释,我的意思是找出哪些变量在特定行中最具影响力

对于python,我曾经这样做:

from treeinterpreter import treeinterpreter as ti
prediction, bias, contributions = ti.predict(rfc, X)

EconAttributes数组拥有我需要的所有信息,然后我可以对其进行操作以获得所需的结果。python中的spark有什么方法可以做到这一点吗?

我想你说的是特性的重要性。 使用管道对象时在pyspark.ml中实现:

tree = model.stages[-1]
# load feature importance from the model object
print(tree.featureImportances)

# You can also print the trees with nodes: 
print('Trees with Nodes: {}'.format(tree.toDebugString))
或者,当您在pyspark.ml中工作而不使用管道时:

from pyspark.ml.classification import RandomForestClassifier
rf = RandomForestClassifier()
model = rf.fit(data)
print(model.featureImportances)

您是否尝试使用model.toDebugString()和MulticlassMetrics?嗯,也许我没有正确解释我的问题?这些事情似乎没有达到我在这里想要达到的目的。我关心的是每个变量对预测结果的贡献(即方差大小)。