|
Medial Code Documentation
|
Functions | |
| Axes | plot_importance (Union[XGBModel, Booster, dict] booster, Optional[Axes] ax=None, float height=0.2, Optional[tuple] xlim=None, Optional[tuple] ylim=None, str title="Feature importance", str xlabel="F score", str ylabel="Features", PathLike fmap="", str importance_type="weight", Optional[int] max_num_features=None, bool grid=True, bool show_values=True, str values_format="{v}", **Any kwargs) |
| GraphvizSource | to_graphviz (Union[Booster, XGBModel] booster, PathLike fmap="", int num_trees=0, Optional[str] rankdir=None, Optional[str] yes_color=None, Optional[str] no_color=None, Optional[dict] condition_node_params=None, Optional[dict] leaf_node_params=None, **Any kwargs) |
| Axes | plot_tree (Booster booster, PathLike fmap="", int num_trees=0, Optional[str] rankdir=None, Optional[Axes] ax=None, **Any kwargs) |
Variables | |
| Axes = Any | |
| GraphvizSource = Any | |
Plotting Library.
| Axes xgboost.plotting.plot_importance | ( | Union[XGBModel, Booster, dict] | booster, |
| Optional[Axes] | ax = None, |
||
| float | height = 0.2, |
||
| Optional[tuple] | xlim = None, |
||
| Optional[tuple] | ylim = None, |
||
| str | title = "Feature importance", |
||
| str | xlabel = "F score", |
||
| str | ylabel = "Features", |
||
| PathLike | fmap = "", |
||
| str | importance_type = "weight", |
||
| Optional[int] | max_num_features = None, |
||
| bool | grid = True, |
||
| bool | show_values = True, |
||
| str | values_format = "{v}", |
||
| **Any | kwargs | ||
| ) |
Plot importance based on fitted trees.
Parameters
----------
booster :
Booster or XGBModel instance, or dict taken by Booster.get_fscore()
ax : matplotlib Axes
Target axes instance. If None, new figure and axes will be created.
grid :
Turn the axes grids on or off. Default is True (On).
importance_type :
How the importance is calculated: either "weight", "gain", or "cover"
* "weight" is the number of times a feature appears in a tree
* "gain" is the average gain of splits which use the feature
* "cover" is the average coverage of splits which use the feature
where coverage is defined as the number of samples affected by the split
max_num_features :
Maximum number of top features displayed on plot. If None, all features will be
displayed.
height :
Bar height, passed to ax.barh()
xlim :
Tuple passed to axes.xlim()
ylim :
Tuple passed to axes.ylim()
title :
Axes title. To disable, pass None.
xlabel :
X axis title label. To disable, pass None.
ylabel :
Y axis title label. To disable, pass None.
fmap :
The name of feature map file.
show_values :
Show values on plot. To disable, pass False.
values_format :
Format string for values. "v" will be replaced by the value of the feature
importance. e.g. Pass "{v:.2f}" in order to limit the number of digits after
the decimal point to two, for each value printed on the graph.
kwargs :
Other keywords passed to ax.barh()
Returns
-------
ax : matplotlib Axes
| Axes xgboost.plotting.plot_tree | ( | Booster | booster, |
| PathLike | fmap = "", |
||
| int | num_trees = 0, |
||
| Optional[str] | rankdir = None, |
||
| Optional[Axes] | ax = None, |
||
| **Any | kwargs | ||
| ) |
Plot specified tree.
Parameters
----------
booster : Booster, XGBModel
Booster or XGBModel instance
fmap: str (optional)
The name of feature map file
num_trees : int, default 0
Specify the ordinal number of target tree
rankdir : str, default "TB"
Passed to graphviz via graph_attr
ax : matplotlib Axes, default None
Target axes instance. If None, new figure and axes will be created.
kwargs :
Other keywords passed to to_graphviz
Returns
-------
ax : matplotlib Axes
| GraphvizSource xgboost.plotting.to_graphviz | ( | Union[Booster, XGBModel] | booster, |
| PathLike | fmap = "", |
||
| int | num_trees = 0, |
||
| Optional[str] | rankdir = None, |
||
| Optional[str] | yes_color = None, |
||
| Optional[str] | no_color = None, |
||
| Optional[dict] | condition_node_params = None, |
||
| Optional[dict] | leaf_node_params = None, |
||
| **Any | kwargs | ||
| ) |
Convert specified tree to graphviz instance. IPython can automatically plot
the returned graphviz instance. Otherwise, you should call .render() method
of the returned graphviz instance.
Parameters
----------
booster :
Booster or XGBModel instance
fmap :
The name of feature map file
num_trees :
Specify the ordinal number of target tree
rankdir :
Passed to graphviz via graph_attr
yes_color :
Edge color when meets the node condition.
no_color :
Edge color when doesn't meet the node condition.
condition_node_params :
Condition node configuration for for graphviz. Example:
.. code-block:: python
{'shape': 'box',
'style': 'filled,rounded',
'fillcolor': '#78bceb'}
leaf_node_params :
Leaf node configuration for graphviz. Example:
.. code-block:: python
{'shape': 'box',
'style': 'filled',
'fillcolor': '#e48038'}
kwargs :
Other keywords passed to graphviz graph_attr, e.g. ``graph [ {key} = {value} ]``
Returns
-------
graph: graphviz.Source