Here is the Java/Scala code snippet which shows how you can get the predictors and response details from H2O POJO and MOJO Models:
to get the list of all column names in your POJO/MOJO model, you can try the following:
import java.io.*; import hex.genmodel.easy.RowData; import hex.genmodel.easy.EasyPredictModelWrapper; import hex.genmodel.easy.prediction.*; import hex.genmodel.MojoModel; import java.util.Arrays;
## First use the POJO model class as below: private static String modelClassName = "gbm_prostate_binomial"; ##Then you can GenModel class to get info you are looking for as below: hex.genmodel.GenModel rawModel; rawModel = (hex.genmodel.GenModel) Class.forName(modelClassName).newInstance(); ## Now you can get the results as below: System.out.println("isSupervised : " + rawModel.isSupervised()); System.out.println("Columns Names : " + Arrays.toString(rawModel.getNames()));
## Lets assume you have MOJO model as gbm_prostate_binomial.zip ## You would need to load your model as below: hex.genmodel.GenModel mojo = MojoModel.load("gbm_prostate_binomial.zip"); ## Now you can get list of predictors as below: System.out.println("isSupervised : " + mojo.isSupervised()); System.out.println("Columns Names : " + Arrays.toString(mojo.getNames()));
To can get help on using MOJO and POJO models visit the following:
That’s it, enjoy!!