pandas_ml.xgboost package

Submodules

class pandas_ml.xgboost.base.XGBoostMethods(df, module_name=None, attrs=None)

Bases: pandas_ml.core.accessor._AccessorMethods

Accessor to xgboost.

XGBClassifier
XGBRegressor
plot_importance(ax=None, height=0.2, xlim=None, title='Feature importance', xlabel='F score', ylabel='Features', grid=True, **kwargs)

Plot importance based on fitted trees.

Parameters:

ax : matplotlib Axes, default None

Target axes instance. If None, new figure and axes will be created.

height : float, default 0.2

Bar height, passed to ax.barh()

xlim : tuple, default None

Tuple passed to axes.xlim()

title : str, default “Feature importance”

Axes title. To disable, pass None.

xlabel : str, default “F score”

X axis title label. To disable, pass None.

ylabel : str, default “Features”

Y axis title label. To disable, pass None.

kwargs :

Other keywords passed to ax.barh()

Returns:

ax : matplotlib Axes

plot_tree(num_trees=0, rankdir='UT', ax=None, **kwargs)

Plot specified tree.

Parameters:

booster : Booster, XGBModel

Booster or XGBModel instance

num_trees : int, default 0

Specify the ordinal number of target tree

rankdir : str, default “UT”

Passed to graphiz 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

to_graphviz(num_trees=0, rankdir='UT', yes_color='#0000FF', no_color='#FF0000', **kwargs)

Convert specified tree to graphviz instance. IPython can automatically plot the returned graphiz instance. Otherwise, you shoud call .render() method of the returned graphiz instance.

Parameters:

num_trees : int, default 0

Specify the ordinal number of target tree

rankdir : str, default “UT”

Passed to graphiz via graph_attr

yes_color : str, default ‘#0000FF’

Edge color when meets the node condigion.

no_color : str, default ‘#FF0000’

Edge color when doesn’t meet the node condigion.

kwargs :

Other keywords passed to graphviz graph_attr

Returns:

ax : matplotlib Axes

Module contents