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
663 stars 110 forks source link

ValueError: Non supported tensor dtype <dtype: 'int8'> for semantic Semantic.CATEGORICAL of feature Maternal_ID #60

Closed mainguyenanhvu closed 3 years ago

mainguyenanhvu commented 3 years ago

I converted a dataframe with dtype int8 into tf.dataset by using tfdf.keras.pd_dataframe_to_tf_dataset. Then, I feed it into tensorflow_decision_forests.RandomForestModel and it returns error:

ValueError: Non supported tensor dtype <dtype: 'int8'> for semantic Semantic.CATEGORICAL of feature Maternal_ID

If I use a dataframe with dtype int32, it runs well.

Please help me explain it.

achoum commented 3 years ago

The currently supported types are currently hard-coded as FlexibleCategoricalIntTypes = [tf.int32, tf.int64]. See https://github.com/tensorflow/decision-forests/blob/main/tensorflow_decision_forests/tensorflow/core.py#L105

The missing types (int8 and int16) will be added in the next release. In the mean time, you will have to apply a cast operation :)

achoum commented 3 years ago

The fix was published in TF-DF 0.2.0.