# tfdf.builder.AbstractBuilder

<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#L182-L581) |

Generic model builder.

    tfdf.builder.AbstractBuilder(
        path: str,
        objective: https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/py_tree/objective/AbstractObjective,
        model_format: Optional[https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/builder/ModelFormat],
        import_dataspec: Optional[data_spec_pb2.DataSpecification],
        input_model_signature_fn: Optional[tf_core.InputModelSignatureFn],
        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

### `close`

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

    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#L297-L301)

    @abc.abstractmethod
    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.

### `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.