pybdt.viz module¶
Visualization functions for PyBDT forests.
- pybdt.viz.dtmodel_to_graphviz(model, title='', emphasis='cuts', leaf_shape='ellipse', split_shape='box', sigfigs=3, float_pretty=True)¶
Plot a
pybdt.DTModel
visualization using graphviz (requires pydot).- Parameters:
model (
pybdt.DTModel
) – The DTModel to visualize.title (str) – Title for the DTModel visualization.
emphasis (str) – Either ‘cuts’ or ‘events’; what style of labeling to use.
leaf_shape (str) – The shape for leaf nodes. (see graphviz shapes)
split_shape (str) –
The shape for split nodes. (see graphviz shapes)
sigfigs (int) – If given, the number of significant digits to use when printing floats.
float_pretty (bool) – Whether to pretty-print scientific notation, or simply use ‘e’ to separate the significand and the exponent.
- pybdt.viz.dtmodel_to_text(model, indent=0, tab_width=2, split_func=None, leaf_func=None)¶
Print a
pybdt.DTModel
visualization to a string.- Parameters:
model (
pybdt.DTModel
) – The DTModel to print.indent (int) – The number of spaces to indent the entire visualization.
tab_width (int) – The amount to increase indentation at each tree level.
split_func (str function (
DTNode
)) – Custom function giving extra information for split DTNodes.leaf_func (str function (
DTNode
)) – Custom function giving extra information for leaf DTNodes.
- Returns:
A string with no newline at the end.
- pybdt.viz.float_to_scientific_notation(x, sigfigs=None, pretty=True, html=False)¶
Create a string representation of x in scientific notation.
- pybdt.viz.variable_importance_to_text(var_imp_dict, indent=0)¶
Get a table of variable importance values.
- Parameters:
var_imp_dict (dict) – One of
BDTModel.weighted_variable_importance()
,BDTModel.unweighted_variable_importance()
,BDTModel.weighted_variable_importance_n_use()
, orBDTModel.unweighted_variable_importance_n_use()
.- Returns:
A str containing the formatted table.