Gus (🤖🧠+🐍+🥑🗣️) Profile picture
AI Developer Advocate @google - Python🐍 - Machine Learning 🤖🧠 - Google AI ⚙️🧠 - DevRel 🥑🗣️ find me also at: https://t.co/3nrTwEJQTs

May 30, 2021, 11 tweets

I've been trying the new TensorFlow Decision Forest (TF-DF) library today and it's very good!

Not only the ease of use but also all the available metadata, documentation and integrations you get!

Let me show you some of the cool things I've learned so far...

[5 min]

1/11🧵

TensorFlow Decision Forests have implemented 3 algorithms:

• CART
• Random Forest
• Gradient Boosted Trees

You can get this list with tfdf.keras.get_all_models()

All of them enable Classification, Regression and Ranking Tasks

2/11🧵

CART or Classification and Regression Trees is a simple decision tree. 🌳

The process divides the dataset in two parts
The first is used to grow the tree while the second is used to prune the tree

This is a good basic algorithm to learn and understand Decision Trees

3/11🧵

Random Forest is the most well-known Decision Forest algorithm. 🌳🌲🌴🎄

It is a collection of CART trees trained on random subsets (with replacement) of the original data

+ It's robust to overfitting

4/11🧵

Gradient Boosted Trees is a set of shallow decision trees trained sequentially. 🌱🌿🌳

The idea is that each tree predicts the gradient of the loss of the model.

+ It usually outperforms Random Forests 👍

5/11🧵

All the implemented algorithms can deal with Numerical and Categorical data without preprocessing.

If you want, you can do it using the Keras Preprocessing or a Pandas Dataframe

The advantage of the Keras solution is that these are saved as part of the final model

6/11🧵

TF-DF makes it easy to plot the trained tree.
As seen in the image:
• Colors are the label distribution
• There's the "if" for the decision per node
• The deeper the node the more pure they become

*This image is better on colab as hovering on nodes shows more info!

7/11🧵

TF-DF also integrates with TensorBoard!

You'll need 3 lines of code to do so! 🤯

8/11🧵

TF-DF can work with other TF models/layers, for example, you can load an language embedding model from #TFHub and use the model as a preprocessing to your Decision tree

9/11🧵

There are many other nice features for inspecting and debugging the model and you can learn more about it on this tutorial notebook

tensorflow.org/decision_fores…

10/11🧵

As you can see, I'm a huge fan of TF-DF and I've played a little bit with it and had a lot of fun!

What do you think? Do you miss any features?

Don't forget to share with more people and follow me for daily ML, TensorFlow and Python content!

11/11🧵

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling