Java

    Quick start

    To apply a previously trained CatBoost model in Java:

    1. Install the package using a package manager.

      Add the following block to the dependencies section of the pom.xml file for Maven:

      <!-- https://mvnrepository.com/artifact/ai.catboost/catboost-prediction -->
      <dependency>
      <groupId>ai.catboost</groupId>
      <artifactId>catboost-prediction</artifactId>
      <version>source_version</version>
      </dependency>
      

      source_version should be set to one of the main CatBoost releases. Available versions can also be checked on the Maven repository site.

    2. Load the trained model:

      import ai.catboost.CatBoostModel;
      import ai.catboost.CatBoostPredictions;
      
      CatBoostModel model = CatBoostModel.loadModel("model.cbm");
      
    3. Apply the model:

      CatBoostPredictions prediction = model.predict(new float[]{0.1f, 0.3f, 0.2f}, new String[]{"foo", "bar", "baz"});
      // assuming that this is a regression task
      System.out.print("model value is " + String.valueOf(prediction.get(0, 0));
      

    Provided classes

    Class Description
    CatBoostModel Basic model application methods.
    CatBoostPredictions A wrapper that provides methods for making convenient predictions for certain classes.