【发布时间】:2021-01-06 03:42:13
【问题描述】:
如何用我的自定义绘图函数替换 dtreeviz 中的节点图?
或者:我想用二维直方图替换 dtreeviz-plots:y-axis=y-values, x-axis: values from the split feature, grid over the plot,每个网格单元获取的数量里面的样品作为颜色。 (如果已经在某些包中实现了也很好)在 matplotlib 中,绘图函数称为 hist2d()
我使用 sklearn 学习回归决策树并使用 dtreeviz 可视化结果。
MWE:(见https://github.com/parrt/dtreeviz#regression-decision-tree)
from sklearn.datasets import *
from sklearn import tree
from dtreeviz.trees import *
regr = tree.DecisionTreeRegressor(max_depth=2)
boston = load_boston()
regr.fit(boston.data, boston.target)
viz = dtreeviz(regr,
boston.data,
boston.target,
target_name='price',
feature_names=boston.feature_names)
viz.view()
现在我的问题中确实有数百万个样本,结果.svg 的显示速度非常慢(读作“不可能”)。我只能通过下采样来使用该可视化。
2d 直方图示例:
(来自https://matplotlib.org/gallery/scales/power_norm.html#sphx-glr-gallery-scales-power-norm-py)
【问题讨论】:
标签: python matplotlib decision-tree dtreeviz