# tfdf.py_tree.tree.Tree

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/py_tree/tree.py#L22-L75) |

A single decision tree.

    tfdf.py_tree.tree.Tree(
        root: Optional[https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/py_tree/node/AbstractNode],
        label_classes: Optional[List[str]] = None
    )

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `label_classes` | <br /> <br /> |
| `root` | <br /> <br /> |

<br />

## Methods

### `pretty`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/py_tree/tree.py#L49-L75)

    pretty(
        max_depth: Optional[int] = 4
    ) -> str

Returns a readable textual representation of the tree.

Unlike `repr(tree)`, `tree.pretty()` format the representation (line return,
margin, hide class names) to improve readability.

This representation can be changed and codes should not try to parse the
output of `pretty`. To access programmatically the tree structure, use
`root()`.

<br />

<br />

<br />

| Args ||
|---|---|
| `max_depth` | The maximum depth of the nodes to display. Deeper nodes are skipped and replaced by "...". If not specified, prints the entire tree. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A pretty-string representing the tree. ||

<br />