【问题标题】:What version of H2O gen-model maven library supports XGBoost MOJO's?哪个版本的 H2O gen-model maven 库支持 XGBoost MOJO?
【发布时间】:2025-12-13 10:50:01
【问题描述】:

我正在尝试使用在运行时使用 java 从 H2O 创建和下载的 XGBoost MOJO,但在编译时出现错误。我尝试了多个不同版本的依赖项,但无法通过它。

依赖关系:

    <dependency>
        <groupId>ai.h2o</groupId>
        <artifactId>h2o-genmodel</artifactId>
        <version>3.22.1.6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/ai.h2o/h2o-genmodel-ext-xgboost -->
    <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("");
    }
}

错误:

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)

【问题讨论】:

    标签: pojo h2o xgboost mojo machine-learning-model


    【解决方案1】:

    我花了一段时间才弄清楚。以下依赖项对我有用。

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

    【讨论】:

      最近更新 更多