Skip to content

API Reference

This page documents the Python API for YDF. Users can also train models using the C++ and CLI APIs.


A Learner trains models and can be cross-validated.

All learners derive from GenericLearner.


A Model makes predictions and can be evaluated.

Note: Models (e.g., GradientBoostedTreesModel) do not contain training capabilities. To train a model, you need to create a learner (e.g., GradientBoostedTreesLearner). Training hyperparameters are constructor arguments of learner classes.

All models derive from GenericModel.


A Tuner finds the optimal set of hyper-parameters using repeated training and evaluation.


  • verbose: Control the amount of logging.
  • load_model: Load a model from disk.
  • Feature: Input feature specific hyper-parameters e.g. semantic, constraints.
  • Column: Alias for Feature.
  • Task: Specify the task solved by the model e.g. classification.
  • Semantic: How an input feature in interpreted e.g. numerical, categorical.
  • start_worker: Start a worker for distributed training.
  • strict: Show more logs.

Advanced Utilities

Custom Loss


The ydf.tree.* classes provides programmatic read and write access to the tree structure, leaves, and values.

  • tree.Tree: A decision tree as returned and consumed by model.get_tree(...) and model.set_tree(...)..