Java

Quick start
To apply a previously trained CatBoost model in Java:
  1. Install the package using a package manager.

    For example, change the source_version line to the latest available version and 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> 
  2. Load the trained model:

    import ai.catboost.CatBoostModel;
    import ai.catboost.CatBoostPredictions;
    
    CatBoostModel model = new CatBoostModel.loadModel("model.cbm");
  3. Apply the model:
    CatBoostPredictions prediction = model.predict(new float[3]{0.1f, 0.3f, 0.2f}, new String[3]{"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.

Class Description
CatBoostModel

Basic model application methods.

CatBoostPredictions

A wrapper that provides methods for making convenient predictions for certain classes.