How to make predict call for javascript converted model

I trained a model using GradientBoostedTreesModel and then converted to javascript. I need help creating the input to make the predict call in javascript.

Saved model with the following command:

I am able to load the model in a web page with:
const model = await tf.loadGraphModel(‘/web_model/model.json’)

In Python, I create the predict input by converting a pandas dataframe to dataset with tfdf.keras.pd_dataframe_to_tf_dataset. The dataframe has 8 columns. How can I do something similar to do the inference? I really only need to predict one set of inputs.


Hello @Dave_H ,

there’s a little tutorial for Running TensorFlow Decision Forests models with TensorFlow.js
Since there’re no Pandas available in JS you could use CSV instead for your input pipeline.
Please have a look here: and

Feel free to share the python code of the inference input (Maybe easier to translate).

Welcome to the Forum,

Thanks! The tutorial was very helpful and I was able to get it to work. The key was to construct the input like this and use executeAsync

const result = await model.executeAsync({
“island”: tf.tensor([“Torgersen”]),
“bill_length_mm”: tf.tensor([39.1]),
“bill_depth_mm”: tf.tensor([17.3]),
“flipper_length_mm”: tf.tensor([3.1]),
“body_mass_g”: tf.tensor([1000.0]),
“sex”: tf.tensor([“Female”]),
“year”: tf.tensor([2007], [1], ‘int32’),

1 Like