TensorFlow Decision Forests
TensorFlow Decision Forests (TF-DF) is a collection of state-of-the-art algorithms for the training, serving and interpretation of Decision Forest models. The library is a collection of Keras models and supports classification, regression and ranking.
TF-DF is a TensorFlow wrapper around the Yggdrasil Decision Forests C++ libraries. Models trained with TF-DF are compatible with Yggdrasil Decision Forests' models, and vice versa.
Usage example
A minimal end-to-end run looks as follow:
import tensorflow_decision_forests as tfdf
import pandas as pd
# Load the dataset in a Pandas dataframe.
train_df = pd.read_csv("project/train.csv")
test_df = pd.read_csv("project/test.csv")
# Convert the dataset into a TensorFlow dataset.
train_ds = tfdf.keras.pd_dataframe_to_tf_dataset(train_df, label="my_label")
test_ds = tfdf.keras.pd_dataframe_to_tf_dataset(test_df, label="my_label")
# Train the model
model = tfdf.keras.RandomForestModel()
model.fit(train_ds)
# Look at the model.
model.summary()
# Evaluate the model.
model.evaluate(test_ds)
# Export to a TensorFlow SavedModel.
# Note: the model is compatible with Yggdrasil Decision Forests.
model.save("project/model")
Documentation & Resources
The following resources are available:
- TF-DF on TensorFlow.org (with the
API Reference and Tutorials) - Colabs
- Migration guide from Neural Network to Decision Forests
- Issue tracker
- Known issues
- Changelog
- Discuss on TensorFlow.Org
- Yggdrasil documentation
(for advanced users and C++ serving) - Tutorials
Installation
To install TensorFlow Decision Forests, run:
pip3 install tensorflow_decision_forests --upgrade
See the installation page for more details,
troubleshooting and alternative installation solutions.