# tfdf.builder.GradientBoostedTreeBuilder

<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/builder/builder.py#L907-L1022) |

Gradient Boosted Tree model builder.

Inherits From: [`AbstractDecisionForestBuilder`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/builder/AbstractDecisionForestBuilder), [`AbstractBuilder`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/builder/AbstractBuilder)

    tfdf.builder.GradientBoostedTreeBuilder(
        path: str,
        objective: https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/py_tree/objective/AbstractObjective,
        bias: Optional[float] = 0.0,
        model_format: Optional[https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/builder/ModelFormat] = https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/builder/ModelFormat#TENSORFLOW_SAVED_MODEL,
        import_dataspec: Optional[data_spec_pb2.DataSpecification] = None,
        input_signature_example_fn: Optional[tf_core.InputModelSignatureFn] = https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/build_default_input_model_signature,
        file_prefix: Optional[str] = None,
        verbose: int = 1,
        advanced_arguments: Optional[https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/builder/AdvancedArguments] = None,
        keras_model_name: Optional[str] = None
    )

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `dataspec` | Dataspec, possibly partially constructed. <br /> Can be called before `close` for advanced model edition. |
| `objective` | Objective of the model. |

<br />

## Methods

### `add_tree`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L667-L672)

    add_tree(
        tree: https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/py_tree/tree/Tree
    )

Adds one tree to the model.

### `check_leaf`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L1012-L1022)

    check_leaf(
        node: https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/py_tree/node/LeafNode
    )

Called on all the leaf nodes during the export.

### `check_non_leaf`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L679-L682)

    check_non_leaf(
        node: https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/py_tree/node/NonLeafNode
    )

Called on all the non-leaf nodes during the export.

### `close`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L991-L1004)

    close()

Finalize the builder work.

This method should be called last.

### `get_dictionary`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L381-L391)

    get_dictionary(
        col_name: str
    ) -> List[str]

Gets the dictionary of a categorical(-set) string feature.

### `model_type`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L988-L989)

    model_type() -> str

Unique key describing the type of the model.

### `observe_feature`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L419-L482)

    observe_feature(
        feature: https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/inspector/SimpleColumnSpec,
        categorical_values: Optional[Union[List[str], List[int]]] = None
    )

Register a feature and some of its possible value.

Generally, users don't need to call this function. An example of advanced
exception is if a model does not refer to a specific possible categorical
value, and if this value should be treated differently than
out-of-vocabulary values.

Should be called at least once on each of the model input features.
If called multiple times with `categorical_values` the set of possible
values will be the union of the `categorical_values`s.

<br />

<br />

<br />

| Args ||
|---|---|
| `feature` | Definition of the feature. |
| `categorical_values` | Set of observed values. Only for categorical-like features. |

<br />

### `set_dictionary`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L393-L417)

    set_dictionary(
        col_name: str, dictionary: List[str]
    ) -> None

Sets the dictionary of a categorical or categorical-set column.

### `specialized_header`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L1006-L1007)

    specialized_header() -> Any

Gets the specialized header of the model.

### `specialized_header_filename`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L1009-L1010)

    specialized_header_filename() -> str

Gets the filename of the specialized header.

### `yggdrasil_model_path`

[View source](https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/component/builder/builder.py#L285-L295)

    yggdrasil_model_path()

Gets the path to the destination yggdrasil model.