tensorflow / decision-forests

A collection of state-of-the-art algorithms for the training, serving and interpretation of Decision Forest models in Keras.
Apache License 2.0
660 stars 110 forks source link

Is there a method like ydf.load_model() to load model get a instance of tfdf.keras.RandomForestModel? #204

Closed huzhenbang closed 10 months ago

huzhenbang commented 10 months ago

In YDF https://ydf.readthedocs.io/en/latest/tutorial/getting_started/#save-model

''' Save model Finally, we use the same model for later use.

model.save("/tmp/my_model") So we can load the model with:

loaded_model = ydf.load_model("/tmp/my_model")

print(f"This is a {loaded_model.name()} model.") '''

I don't find a method to load model to get a instance of tfdf.keras.RandomForestModel.

I found when I use dtreeviz to get some visual information I must retrain the model again. This is so frustrating. Is there a better way?

rstz commented 10 months ago

Hi,

due to limitations of the Keras API, it's not possible to obtain the same model after saving and re-loading. I know this is very frustrating, and it's one of the reasons using ydf instead of tfdf can be a good idea. I don't think dtreeviz has support for ydf yet, but adding it should be easy - maybe open a FR in their repository and cc me to it?

huzhenbang commented 10 months ago

Thanks.