random forest - h2o randomforest not predicting on a categorical value which not seen during training, It's giving exception -
we using prediction service builder using java pojo serving our model. when pass new categorical value of feature model haven't seen before while training. gives exception. how can handle ?
the java pojo , mojo documentation h2o-3 here:
the relevant example @ pojo level pasted below:
string modelclassname = "gbm_pojo_test"; hex.genmodel.genmodel rawmodel; rawmodel = (hex.genmodel.genmodel) class.forname(modelclassname).newinstance(); // default, unknown categorical levels throw predictunknowncategoricallevelexception. // optionally configure wrapper treat unknown categorical levels n/a instead // , strings cannot converted numbers n/as: easypredictmodelwrapper model = new easypredictmodelwrapper( new easypredictmodelwrapper.config() .setmodel(rawmodel) .setconvertunknowncategoricallevelstona(true) .setconvertinvalidnumberstona(true) );
incidentally, if use mojos instead of pojos, won't have compile drf java model code @ all, can issue large models. here example project builds tree model, exports mojo, creates war file, , deploys in simple java servlet container:
Comments
Post a Comment