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

How to use tfdf for regression? #96

Closed Jack8861 closed 2 years ago

Jack8861 commented 2 years ago

I have tried to add Task=core.Task.REGRESSION argument to both the pd_dataframe_to_tf_dataset and model (all) but i get this error.

train_data = pd_dataframe_to_tf_dataset(car, label="price", task=core.Task.REGRESSION,)
model = tfdf.keras.RandomForestModel()
model.fit(train_data, task=core.Task.REGRESSION,)

ValueError: The model'staskattribute (CLASSIFICATION) does not match thetaskattribute passed topd_dataframe_to_tf_dataset(REGRESSION).

And ofcourse If i don't add core.Task.REGRESSION to pd_dataframe_to_tf_dataset i get the error

ValueError: The number of unique classes (189) exceeds max_num_classes (100). A high number of unique value / classes might indicate that the problem is a regression or a ranking instead of a classification. If this problem is effectively a classification problem, increasemax_num_classes`.

Jack8861 commented 2 years ago

Sorry my bad. This works.

train_data = pd_dataframe_to_tf_dataset(car, label="price", task=core.Task.REGRESSION,)
model = tfdf.keras.RandomForestModel( task=core.Task.REGRESSION)
model.fit(train_data)_