I am trying to use XGBoost MOJO created and downloaded from H2O in runtime using java, but I am getting errors while compiling. I have tries multiple different versions of dependencies but couldn't get through it.

Dependencies :

 <dependency> <groupId>ai.h2o</groupId> <artifactId>h2o-genmodel</artifactId> <version>3.22.1.6</version> </dependency> <!-- --> <dependency> <groupId>ai.h2o</groupId> <artifactId>h2o-genmodel-ext-xgboost</artifactId> <version>3.24.0.1</version> <type>pom</type> </dependency> 

Main.java

import hex.genmodel.easy.EasyPredictModelWrapper; import hex.genmodel.easy.RowData; import hex.genmodel.easy.prediction.BinomialModelPrediction; public class Main { public static void main(String[] args) throws Exception { EasyPredictModelWrapper model = new EasyPredictModelWrapper( MojoModel.load("/Users/p0g0085/Downloads/grid_5dd10c7e_297d_42eb_b422_56c687ba85df_model_18.zip")); RowData row = new RowData(); row.put("brand", "Great Value"); row.put("product_type", "Cheeses"); row.put("duration", "21.0"); row.put("quantity", "1.0"); row.put("ghs_frequency", "11.3714"); BinomialModelPrediction p = model.predictBinomial(row); System.out.println("Has penetrated the prostatic capsule (1=yes; 0=no): " + p.label); System.out.print("Class probabilities: "); for (int i = 0; i < p.classProbabilities.length; i++) { if (i > 0) { System.out.print(","); } System.out.print(p.classProbabilities[i]); } System.out.println(""); } } 

Error :

Exception in thread "main" java.lang.IllegalStateException: Algorithm `XGBoost` is not supported by this version of h2o-genmodel. If you are using an algorithm implemented in an extension, be sure to include a jar dependency of the extension (eg.: ai.h2o:h2o-genmodel-ext-xgboost) at hex.genmodel.ModelMojoFactory.getMojoReader(ModelMojoFactory.java:102) at hex.genmodel.ModelMojoReader.readFrom(ModelMojoReader.java:31) at hex.genmodel.MojoModel.load(MojoModel.java:37) at Main.main(Main.java:9) 

1 Answer

It took me a while to figure out. Below dependency worked for me.

 <dependency> <groupId>ai.h2o</groupId> <artifactId>h2o-genmodel-ext-xgboost</artifactId> <version>3.22.0.3</version> </dependency> 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.