# Install TF-DF !pip install tensorflow tensorflow_decision_forests # Load TF-DF 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 library to train, run and interpret decision forest models (e.g., Random Forests, Gradient Boosted Trees) in TensorFlow. TF-DF supports classification, regression, ranking and uplifting. It is available on Linux and Mac. Window users can use WSL+Linux.
Keywords: Decision Forests, TensorFlow, Random Forest, Gradient Boosted Trees, CART, model interpretation.
Documentation & Resources
The following resources are available:
- Guides and tutorials
- API reference
- YDF documentation (also applicable to TF-DF)
- Google Developers class on decision forests
- Use Simple ML for Sheets to train models in your Google Sheets
Contributions to TensorFlow Decision Forests and Yggdrasil Decision Forests are welcome. If you want to contribute, make sure to review the developer manual.