# Module: tfdf.tuner

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

Specification of the parameters of a tuner.

The "tuner" is a meta-learning algorithm that find the optimal hyperparameter
values of a base learner. "Tuner" is the TF-DF name for the YDF automatic
Hyperparameter optimizer V2. For example, a tuner can find the hyper-parameters
that maximize the accuracy of a GradientBoostedTreesModel model.

#### Usage example:

    # Imports
    import tensorflow_decision_forests as tfdf

    # Load a dataset into a Pandas Dataframe.
    dataset_df = pd.read_csv("/tmp/penguins.csv")

    # Convert the Pandas dataframe to a tf dataset
    tf_dataset = tfdf.keras.pd_dataframe_to_tf_dataset(dataset_df,label="species")

    # Configure the tuner.
    tuner = tfdf.tuner.RandomSearch(num_trials=20)
    tuner.choice("num_candidate_attributes_ratio", [1.0, 0.8, 0.6])
    tuner.choice("use_hessian_gain", [True, False])

    local_search_space = tuner.choice("growing_strategy", ["LOCAL"])
    local_search_space.choice("max_depth", [4, 5, 6, 7])

    global_search_space = tuner.choice(
        "growing_strategy", ["BEST_FIRST_GLOBAL"], merge=True)
    global_search_space.choice("max_num_nodes", [16, 32, 64, 128])

    # Configure and train the model.
    model = tfdf.keras.GradientBoostedTreesModel(num_trees=50, tuner=tuner)
    model.fit(tf_dataset)

## Classes

[`class HPOptProto`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/tuner/HPOptProto): A ProtocolMessage

[`class RandomSearch`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/tuner/RandomSearch): Tuner using random hyperparameter values.

[`class SearchSpace`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/tuner/SearchSpace): Set of hyperparameter and their respective possible values.

[`class TrainConfig`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/keras/core/YggdrasilTrainingConfig): A ProtocolMessage

[`class Tuner`](https://www.tensorflow.org/decision_forests/api_docs/python/tfdf/tuner/Tuner): Abstract tuner class.

<br />

<br />

<br />

| ## Other Members ||
|---|---|
| annotations | Instance of `__future__._Feature` |

<br />