Catboost error while envoking WIT

31 views
Skip to first unread message

sumit joshi

unread,
Feb 28, 2023, 8:57:49 AM2/28/23
to What-If Tool
Hi,
I got the CatBoost error in WIT  while I was using CatBoost regression as a custom predict function. I think the tf.examples not supported to catboost.predict method.
Please guide me regarding this.
Below I am writing my code. Please have look at it.
Also, I have already encoded the catgorical feature
from catboost import CatBoostRegressor as CatB
reg_catb = CatB(iterations=20000, max_depth=8, random_state=0, learning_rate=0.024,
               # cat_features=cat_feature,
               ).fit(X_train, y_train,plot=True)
def custom_predict(examples_to_infer):
    model_ins= examples_to_infer
    preds=reg_catb.predict(model_ins)    
    return preds

tool_height_in_px=1000

# Setup the tool with the test examples and the trained regressor model
config_builder = WitConfigBuilder(test_examples2[0:]).set_custom_predict_fn(custom_predict).set_model_type('regression')
a=WitWidget(config_builder,height=tool_height_in_px)

jwe...@google.com

unread,
Feb 28, 2023, 9:00:12 AM2/28/23
to What-If Tool
You most likely need to convert the examples passed to the custom_predict function into whatever format the model expects examples in. Then you should convert the output of the model's predict function into the form that the What-If tool expects, assuming they are different.

sumit joshi

unread,
Feb 28, 2023, 9:47:27 AM2/28/23
to What-If Tool
Thank you for your quick response. The issue has been resolved.
Reply all
Reply to author
Forward
0 new messages