# Module: tfdf.keras

<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/keras/__init__.py) |

Decision Forest in a Keras Model.

#### Usage example:

    import tensorflow_decision_forests as tfdf
    import pandas as pd

    # Load the dataset in a Pandas dataframe.
    train_df = pd.read_csv("project/train.csv")
    test_df = pd.read_csv("project/test.csv")

    # Convert the dataset into a TensorFlow dataset.
    train_ds = tfdf.keras.pd_dataframe_to_tf_dataset(train_df, label="my_label")
    test_ds = tfdf.keras.pd_dataframe_to_tf_dataset(test_df, label="my_label")

    # Train the model.
    model = tfdf.keras.RandomForestModel()
    model.fit(train_ds)

    # Evaluate the model on another dataset.
    model.evaluate(test_ds)

    # Show information about the model
    model.summary()

    # Export the model with the TF.SavedModel format.
    model.save("/path/to/my/model")

    # ...

    # Load a model: it loads as a generic keras model.
    loaded_model = tf_keras.models.load_model("/path/to/my/model")

## Modules

[`core`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/core) module: Core wrapper.

[`wrappers`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/wrappers) module: Wrapper around each learning algorithm.

## Classes

[`class AdvancedArguments`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/AdvancedArguments): Advanced control of the model that most users won't need to use.

[`class CartModel`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/CartModel): Cart learning algorithm.

[`class CoreModel`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/CoreModel): Keras Model V2 wrapper around an Yggdrasil Learner and Model.

[`class DistributedGradientBoostedTreesModel`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/DistributedGradientBoostedTreesModel): Distributed Gradient Boosted Trees learning algorithm.

[`class FeatureSemantic`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/FeatureSemantic): Semantic (e.g.

[`class FeatureUsage`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/FeatureUsage): Semantic and hyper-parameters for a single feature.

[`class GradientBoostedTreesModel`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/GradientBoostedTreesModel): Gradient Boosted Trees learning algorithm.

[`class Monotonic`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/Monotonic): Monotonic constraint between a feature and the model output.

[`class MultiTaskItem`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/MultiTaskItem): A single task in a multi-task configuration.

[`class RandomForestModel`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/RandomForestModel): Random Forest learning algorithm.

## Functions

[`build_default_feature_signature(...)`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/build_default_feature_signature): Gets an example of feature values for the default model signature.

[`build_default_input_model_signature(...)`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/build_default_input_model_signature)

[`get_all_models(...)`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/get_all_models): Gets the lists of all the available models.

[`get_worker_idx_and_num_workers(...)`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/get_worker_idx_and_num_workers): Gets the current worker index and the total number of workers.

[`pd_dataframe_to_tf_dataset(...)`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/pd_dataframe_to_tf_dataset): Converts a Panda Dataframe into a TF Dataset compatible with Keras.

[`set_training_logs_redirection(...)`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/set_training_logs_redirection): Controls the redirection of training logs for display.

[`yggdrasil_model_to_keras_model(...)`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/yggdrasil_model_to_keras_model): Converts an Yggdrasil model into a TensorFlow SavedModel / Keras model.

<br />

<br />

<br />

| ## Other Members ||
|---|---|
| Task | Instance of `google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper` |

<br />