Attend the Women in ML Symposium on December 7 Register now


Stay organized with collections Save and categorize content based on your preferences.

Installation with Pip

Install TensorFlow Decision Forests by running:

# Install TensorFlow Decision Forests.
pip3 install tensorflow_decision_forests --upgrade

Then, check the installation with by running:

# Check the version of TensorFlow Decision Forests.
python3 -c "import tensorflow_decision_forests as tfdf; print('Found TF-DF v' + tfdf.__version__)"

Build from source




  • Bazel >= 3.7.2
  • Python >= 3
  • Git
  • Python packages: numpy tensorflow pandas

Instead of installing the dependencies by hands, you can use the TensorFlow Build docker. If you choose this options, install Docker:


Download TensorFlow Decision Forests as follows:

# Download the source code of TF-DF.
git clone
cd decision-forests

Optional: TensorFlow Decision Forests depends on Yggdrasil Decision Forests . If you want to edit the Yggdrasil code, you can clone the Yggdrasil github and change the path accordingly in third_party/yggdrasil_decision_forests/workspace.bzl.

Optional: If you want to use the docker option, run the script and continue to the next step. If you don't want to use the docker option, continue to the next step directly.

# Optional: Install and start the build docker.

Compile and run the unit tests of TF-DF with the following command. Note that is configured for python3.8 and the default compiler on your machine. Edit the file directly to change this configuration.

# Build and test TF-DF.

Create and test a pip package with the following command. Replace python3.8 by the version of python you want to use. Note that you don't have to use the same version of Python as in the script.

If your configuration is compatible with manylinux2014, a manylinux2014 compatible pip package will be produced.

If your configuration is not compatible with manylinux2014, a non manylinux2014 compatible pip package will be produced, and the final check will fail. It does not matter if you want to use TF-DF on your own machine. An easy way to make the build manylinux2014 compatible is to use the docker mentioned above.

# Build and test a Pip package.
./tools/ python3.8

This command will install the TF-DF pip package and run the example in examples/ The Pip package is located in the dist/ directory.

If you want to create a Pip package for the other compatible version of Python, run:

# Install the other versions of python (assume only python3.8 is installed; this is the case in the build docker).
sudo apt-get update && sudo apt-get install python3.7 python3.9 python3-pip

# Create the Pip package for the other version of python
./tools/ python3.7
./tools/ python3.9

Alternatively, you can create the pip package for all the compatible version of python using pyenv by running the following command. See the header of tools/ for more details.

# Build and test all the Pip package using Pyenv.




  • Coreutils (tested with brew install coreutils)
  • Bazel >= 3.7.2
  • Python >= 3 (tested with brew install python)
  • Git
  • JDK 11
  • Python packages: numpy tensorflow pandas


Follow the same steps as for the linux compilation without Docker.

Final note

Compiling TF-DF relies (since 17th Dec. 2021) on the TensorFlow Pip package and the TensorFlow Bazel dependency. A small part of TensorFlow will be compiled. Compiling TF-DF on a single powerful workstation takes ~10 minutes.