Skip to content

YDF is a library to train, evaluate, interpret, and serve Random Forest,
Gradient Boosted Decision Trees, and CART decision forest models.

Getting Started 🧭

A concise and modern API
YDF allows for rapid prototyping and development while minimizing risk of modeling errors.
Deep learning composition
Integrated with TensorFlow, Keras, and Vertex AI.
Cutting-edge algorithms
Include the latest decision forest research to ensure maximum performance.
Fast inference
Compute predictions in a few microseconds. Executed in the tens of millions of times per second in Google.

Key features



Advanced modeling

  • Compose YDF models with Neural Network models in TensorFlow, Keras, and JAX.
  • Distributed training over billions of examples and hundreds of machines.
  • Use cutting-edge learning algorithm such as oblique splits, honest trees, hessian scores, global tree optimizations, optimal categorical splits, categorical-set inputs, dart, extremely randomized trees.
  • Apply monotonic constraints.
  • Consumes multi-dimensional features.
  • Enjoy backward compatibility for model and learners since 2018.
  • Edits trees in Python.
  • Define custom loss in Python.

Supported platforms

YDF is available on Python 3.8, 3.9, 3.11 and 3.12, on Windows x86-64, Linux x86-64, and macOS ARM64.


To install YDF from PyPI, run:

pip install ydf -U

Usage example

Open in Colab

import ydf
import pandas as pd

# Load dataset with Pandas
ds_path = ""
train_ds = pd.read_csv(ds_path + "adult_train.csv")
test_ds = pd.read_csv(ds_path + "adult_test.csv")

# Train a Gradient Boosted Trees model
model = ydf.GradientBoostedTreesLearner(label="income").train(train_ds)

# Look at a model (input features, training logs, structure, etc.)

# Evaluate a model (e.g. roc, accuracy, confusion matrix, confidence intervals)

# Generate predictions

# Analyse a model (e.g. partial dependence plot, variable importance)

# Benchmark the inference speed of a model

# Save the model"/tmp/my_model")

Next steps

Read the 🧭 Getting Started tutorial. You will learn how to train a model, interpret it, evaluate it, generate predictions, benchmark its speed, and export it for serving.

Ask us questions on Github. Googlers can join the internal YDF Chat.

Read the TF-DF to YDF Migration guide to convert a TensorFlow Decision Forests pipeline into a YDF pipeline.