View source on GitHub |
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
: A ProtocolMessage
class RandomSearch
: Tuner using random hyperparameter values.
class SearchSpace
: Set of hyperparameter and their respective possible values.
class TrainConfig
: A ProtocolMessage
class Tuner
: Abstract tuner class.
Other Members | |
---|---|
annotations |
Instance of __future__._Feature
|