Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mojo-resource tutorial #162

Open
bvandorf opened this issue Aug 14, 2022 · 0 comments
Open

mojo-resource tutorial #162

bvandorf opened this issue Aug 14, 2022 · 0 comments

Comments

@bvandorf
Copy link

Hi,

In the mojo-resource tutorial, you show how to predict from a java application, during my testing I was unable to predict anything other than the default prediction shown in the tutorial even by specifically setting the testRow variable.

https://github.com/h2oai/h2o-tutorials/tree/master/tutorials/mojo-resource

`

    URL mojoURL = Main.class.getResource("irisgbm.zip");
    MojoReaderBackend reader = MojoReaderBackendFactory.createReaderBackend(mojoURL, 
    MojoReaderBackendFactory.CachingStrategy.MEMORY);
    MojoModel model = ModelMojoReader.readFrom(reader);
    EasyPredictModelWrapper modelWrapper = new EasyPredictModelWrapper(model);
    
    RowData testRow = new RowData();
    for (int i = 0; i < args.length; i++)
    {
        testRow.put("C"+i, Double.valueOf(args[i]));
    }
    if (testRow.size() == 0)
    {
        System.out.println("Add test values to testRow");
        testRow.put("C0", 5.1);
        testRow.put("C1", 3.5);
        testRow.put("C2", 1.4);
        testRow.put("C3", 0.2);
    }
    System.out.println("C0: " + testRow.get("C0"));
    System.out.println("C1: " + testRow.get("C1"));
    System.out.println("C2: " + testRow.get("C2"));
    System.out.println("C3: " + testRow.get("C3"));
    System.out.println("");
    
    MultinomialModelPrediction prediction = (MultinomialModelPrediction)modelWrapper.predict(testRow);
    
    for (int i = 0; i < prediction.classProbabilities.length; i++)
        System.out.println(modelWrapper.getResponseDomainValues()[i] + ": "+ prediction.classProbabilities[i]);
    System.out.println("Prediction: " + prediction.label);
    System.out.println("Prediction Index: " + prediction.labelIndex);

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant