CLI tool
tensorflow/decision-forests avatar
tensorflow/decision-forests

TF-DF: Decision Forests Inside Keras, and the Migration Note at the Top of the README

A collection of state-of-the-art algorithms for the training, serving and interpretation of Decision Forest models in Keras.

693 stars115 forksPythonApache-2.0

At a glance

What is it?
TensorFlow Decision Forests trains Random Forests, Gradient Boosted Trees and ranking models as Keras models, backed by the Yggdrasil Decision Forests C++ engine. The README's first line tells new users to move to YDF instead, which shapes the adoption decision more than any feature list.
Who is it for?
Adopt TF-DF when the training pipeline is already Keras and you need tree models that save as SavedModels and evaluate through model.evaluate; the README's own recommendation to migrate to YDF means new projects should weigh the two APIs before writing code. Skip it if you need Windows without WSL, or if you want the library's own maintainers to keep extending the Keras surface.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 119 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The gap TF-DF fills: trees that behave like Keras layers

Gradient boosted trees and random forests usually live outside the TensorFlow graph. You train them in a separate library, then either serve them through a bespoke runtime or hand-write a bridge into the model you actually deploy. TF-DF removes that seam for teams already inside TensorFlow. The model classes subclass Keras, so fit, evaluate, summary and save are the same calls used for a neural network, and the README's minimal example shows exactly that shape: build a tf.data.Dataset with pd_dataframe_to_tf_dataset, call model.fit(train_ds), then model.save("project/model") to produce a TensorFlow SavedModel.

The audience is narrow but real. It is for engineers who want a tree baseline or a production tree model inside a Keras workflow, and who care about interpretability enough that the repository lists it as a topic. It supports classification, regression and ranking. It is not a general AutoML tool and it does not try to replace scikit-learn for quick experiments on small data.

YDF underneath: the C++ engine and what Keras wraps

TF-DF is a Python surface over Yggdrasil Decision Forests, a C++ library that also ships JavaScript, CLI and Go bindings. The README states that TF-DF is "powered by" YDF and that the two model formats are compatible in both directions, with a conversion page in the YDF documentation. That architecture explains most of the library's behaviour: training happens in the C++ engine, while the Keras class handles dataset conversion, the fit loop and export.

The practical consequence is that TF-DF's capabilities track YDF's. When the README says YDF "trains the same models as TF-DF, but is faster and has more functionality", it is describing a wrapper that lags its own engine. For an adopter this matters at the edges: a model class or training option present in YDF may not have been surfaced in the Keras API yet. The SavedModel export path is the reason to stay, since that is what TF-DF adds over calling YDF directly.

Installation and the Windows constraint

Installation is a single command:

pip3 install tensorflow_decision_forests --upgrade

The README points to documentation/installation.md for troubleshooting and alternative installs, and the repository carries a documentation/known_issues.md file, which is worth reading before pinning a version in CI.

Platform support is the first real constraint. The README states TF-DF is available on Linux and Mac, and that Windows users can use it through WSL plus Linux. There is no native Windows path described. If your build agents are Windows containers, this is a blocker rather than an inconvenience, because the workaround changes the environment your pipeline runs in. Python is the only language listed for this repository, though the underlying YDF engine has bindings the README enumerates separately.

The migration note is the most important line in the README

The README opens with a note recommending that users migrate to Yggdrasil Decision Forests, stating that YDF trains the same models but is faster and has more functionality, and linking a migration guide. That is unusual placement. A project's front page normally argues for adoption; this one points elsewhere.

Read carefully, the note is about the API layer, not about abandonment. TF-DF is not archived, and the release list shows v1.12.0 in March 2025 and v1.10.1 later that same month, so the Keras wrapper is still being published. But a maintainer-recommended successor changes the calculus for anyone starting fresh. If you write TF-DF code today, you are choosing the wrapper the project itself suggests you leave, and you should assume new functionality lands in YDF first. The counter-argument is concrete: TF-DF is the path to a TensorFlow SavedModel, and if that artifact is what your serving stack consumes, the migration is not free.

Training, evaluation and export in one object

The documented flow is short. Convert a Pandas dataframe with pd_dataframe_to_tf_dataset, passing the label column name. Instantiate tfdf.keras.RandomForestModel with no arguments. Fit, inspect with model.summary(), score with model.evaluate(test_ds), then save. The README's comment on the save call notes that the exported model is compatible with Yggdrasil Decision Forests, which means the artifact is not locked to the Keras runtime.

What the README does not show is the tuning surface. There is no example of hyperparameter configuration, no discussion of how training time scales, and no benchmark. Those details live in the external documentation links and the YDF docs, which the README says are "also applicable to TF-DF". Treat the README as a pointer, not a manual.

Where TF-DF is the wrong tool, and what to use instead

The clearest failure case is a Windows-native environment. WSL is a real answer, but it changes where your code runs, and for teams with Windows-only CI the cost is not trivial.

The second case is training speed and feature coverage. The README's own migration note says YDF is faster and has more functionality, so if you are not constrained by Keras or by SavedModel export, TF-DF is the slower and narrower option by the project's own description.

The third case is outside the TensorFlow ecosystem entirely. CatBoost and XGBoost are the obvious alternatives, and the difference is architectural rather than a matter of quality. Both are standalone gradient boosting libraries with their own training loops, their own model formats and their own serving options; neither is a Keras model class, and neither exports a TensorFlow SavedModel as its primary artifact. If your stack is Python plus a model file loaded by a native runtime, that independence is an advantage. TF-DF's value is precisely the integration those libraries do not offer, so the choice reduces to whether Keras integration is worth the wrapper's constraints.

Maintenance cost, versioning and the licence

The release history is uneven. v1.11.0 landed in October 2024, then v1.12.0 in March 2025, followed by v1.10.1 later that same month. A patch release carrying a lower version number than a release published two weeks earlier is worth understanding before you pin a version, because it suggests a backport to an older line rather than a normal forward release. Check the CHANGELOG before locking a dependency.

The upgrade cost is coupled to TensorFlow. TF-DF is a Keras library, so a TensorFlow upgrade can force a TF-DF upgrade, and the reverse. Budget for testing both together rather than treating TF-DF as an isolated dependency.

Licensing is Apache-2.0, the same licence as TensorFlow itself. That is a permissive licence with an explicit patent grant and attribution requirements, but this is a description of the licence file, not legal advice; if you redistribute the library or a derivative, have counsel review the notice obligations.

Editorial conclusion

Adopt TF-DF when the training pipeline is already Keras and you need tree models that save as SavedModels and evaluate through model.evaluate; the README's own recommendation to migrate to YDF means new projects should weigh the two APIs before writing code. Skip it if you need Windows without WSL, or if you want the library's own maintainers to keep extending the Keras surface. Before committing, verify three things: that pip3 install tensorflow_decision_forests --upgrade resolves for your Python version, that the platform is Linux or macOS rather than native Windows, and whether the YDF migration guide covers the model classes you intend to use.

Official sources

  1. Issues
  2. License: Apache-2.0
  3. README
  4. Releases
  5. tensorflow/decision-forests on GitHub
Community notes

Community notes