import tensorflow_decision_forests as tfdf import pandas as pd # Load a 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 a Random Forest model. model = tfdf.keras.RandomForestModel() model.fit(train_ds) # Summary of the model structure. model.summary() # Evaluate the model. model.evaluate(test_ds) # Export the model to a SavedModel. model.save("project/model")
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 wrapper around the Yggdrasil Decision Forest C++ libraries. Models trained with TF-DF are compatible with Yggdrasil Decision Forests' models, and vice versa.
Keywords: Decision Forests, TensorFlow, Random Forest, Gradient Boosted Trees, CART, model interpretation.
The following resources are available:
- Discuss on discuss.tensorflow.org
- Issue tracker
- TensorFlow Decision Forest on Github
- Yggdrasil Decision Forest on Github
Contributions to TensorFlow Decision Forests and Yggdrasil Decision Forests are welcome. If you want to contribute, make sure to review the developer manual.