How do I visualise / plot a decision tree in Apache Spark (PySpark 1.4.1)?

眉间皱痕 提交于 2019-12-05 11:05:42
Vishnu667

There is this project Decision-Tree-Visualization-Spark for visualizing decision tree model

It has two steps

  • Parse Spark Decision Tree output to a JSON format.
  • Use the JSON file as an input to a D3.js visualization.

For the parser check Dt.py

The input to the function def tree_json(tree) is your models toDebugString()

Answer from question

Though this is a little old post, just to provide my answer so that others coming to this post from now on can be benefitted.

Alternatively you can use "graphviz" python Package for use in PySpark. It will print the decision tree model into a neat tree structure rather than usual if loop structure.

More details can be found in this link : https://pypi.python.org/pypi/graphviz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!