sklearn_fab.utils¶
export_gate_tree_dot¶
- sklearn_fab.utils.export_gate_tree_dot(estimator, out_file=None, X=None)¶
Create and export dot data of gate tree from the model.
- Parameters:
- estimatorSklearnFABEstimator
A fitted SklearnFABEstimator instance.
- out_filestr or None, optional [default: None]
Output file path. It must be .dot file. If out_file is None, dot_data will not be exported on an external file. If out_file path already exists, the existing file will be overwritten. Any nonexistent intermediate directories will be made automatically.
- Xarray-like or None, optional [default: None]
Feature data. Specifying this parameter would include the number of samples of the feature data distributed to each gate and component.
- Returns:
- dot_datapydot.Dot
Dot representation of the input tree in GraphViz dot format.
- Raises:
- NotFittedError
If this function is called before estimator is fitted.
- TypeError
estimator is not supported type. Only SklearnFABEstimators are supported.
out_file is not str or None.
- ValueError
out_file extension is not ‘.dot’.
X cannot be converted to array-like object.
- The number of columns of X is not equal to the number of features data
which is used when estimator was fitted.
Notes
pydot is a Graphviz’s dot language python interface. For more information, please refer to the following documentation. https://github.com/pydot/pydot
Examples
>>> from sklearn_fab.utils import export_gate_tree_dot >>> from sklearn_fab import SklearnFABBernGateLinearRegressor >>> from sklearn.datasets import load_boston >>> boston = load_boston() >>> rg = SklearnFABBernGateLinearRegressor() >>> rg.fit(boston.data, boston.target) >>> export_gate_tree_dot(rg, './fab_gate_tree.dot', boston.data) <pydot.Dot at 0x7f4cfc20d7f0>
Output Format¶
The output is a pydot.Dot object or .dot file. It can be used to create an image file like PNG format below.
Example of Bernoulli-gating function image:

Node (box-shaped) contents
Conditional expression
The number of samples passed down to the node
Leaf (ellipse-shaped) contents
The component ID
The number of samples assigned to the component