0

I try to locally compile a POJO of a GBM prediction model generated with H2o 3.8.1.3; I follow the instructions in the POJO class:

  • create a folder
  • Download the h2o-genmodel.jar into the folder with:

    curl http://myh2oinstancesurl:myh2oinstancesport/3/h2o-genmodel.jar > h2o-genmodel.jar
    
  • Download the successfully trained GBM model named 154 into the folder with:

    curl http://myh2oinstancesurl:myh2oinstancesport/3/Models/154/java > 154.java
    
  • Compile the sources in the folder with javac 1.8.0_45 under Max OSX 10.11.3 or Fedora 23:

     javac -cp h2o-genmodel.jar 154.java
    
  • Result are a bunch of compilation errors:

    154.java:24: error: <identifier> expected
    public class 154 extends GenModel {
            ^
    154.java:24: error: illegal start of type
    public class 154 extends GenModel {
                 ^
    154.java:24: error: ';' expected
    public class 154 extends GenModel {
                                 ^
    154.java:25: error: illegal start of expression
      public hex.ModelCategory getModelCategory() { return hex.ModelCategory.Binomial; }
      ^
    154.java:25: error: ';' expected
       public hex.ModelCategory getModelCategory() { return hex.ModelCategory.Binomial; }
                                           ^
    154.java:27: error: illegal start of expression
       public boolean isSupervised() { return true; }
      ^
    154.java:27: error: ';' expected
      public boolean isSupervised() { return true; }
                             ^
    154.java:28: error: illegal start of expression
      public int nfeatures() { return 14; }
      ^
    154.java:28: error: ';' expected
      public int nfeatures() { return 14; }
                      ^
    154.java:29: error: illegal start of expression
      public int nclasses() { return 2; }
      ^
    

    ...

    100 errors
    

    Is there an issue with my procedure? Or is this a bug with my setup? Is there anybody who currently can compile GBM POJOs? Thanks for your responses!

p_r
  • 41
  • 5

2 Answers2

0

Solved: The problem was that the POJO class name obviously has to be a valid java class name; a purely numeric name is not allowed. Changing the model name resolves the issue.

p_r
  • 41
  • 5
0

[ This is not a direct answer to the question, but hopefully a helpful pointer to anyone that finds this question... ]

Since this question was asked, H2O has also added the ability to export a MOJO and use it for making predictions.

An H2O POJO is a code representation of a model, and an H2O MOJO is a data representation of a model.

A MOJO can be used in the same way as a POJO, and MOJOs do not need to be compiled (they are interpreted instead). This is especially useful for very large tree models, where trying to compile them has various technical challenges around gigabytes of code size. So in many cases, the best way to address a compilation issue is to not compile at all.

The online documentation for both H2O POJOs and MOJOs can be found here:

I hope people find this (delayed) answer helpful.

TomKraljevic
  • 3,661
  • 11
  • 14