YDF (short for Yggdrasil Decision Forests) is a library for training, serving, evaluating, and analyzing decision forest models such as Random Forest and Gradient Boosted Trees. It acts as a lightweight, efficient wrapper around the C++ Yggdrasil Decision Forests library. YDF is the official successor to TensorFlow Decision Forests (TF-DF) and is recommended for new projects due to its superior performance and features. It is actively developed with frequent releases.
pip install ydf -UVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install YDF, import the library, load a sample dataset using Pandas, train a Gradient Boosted Trees model, evaluate its performance, make predictions, and save/load the trained model. It uses the 'Adult' dataset for a binary classification task.
Install `ydf-tf` (`pip install ydf-tf`) and use the recommended export methods provided by `ydf-tf` if TensorFlow SavedModel export is necessary.
Upgrade your Python environment to version 3.9 or higher.
For reproducible results, ensure your input dataset (columns, order, values) and YDF version are strictly identical across training runs, and explicitly set a random seed if available for stochastic parts of the algorithm.
Set `verbose=0` to suppress all logs or `verbose=2` to print all logs on all surfaces (e.g., notebook and console) if detailed debugging is needed.
Update your code to use `LAMBDA_MART_NDCG` for ranking tasks. The old name is deprecated but still functions.