Skip to content

Click in-app to access the full platform documentation for your version of DataRobot.

Scoring Code usage examples

Availability information

Contact your DataRobot representative for information on enabling the Scoring Code feature.

Models displaying the SCORING CODE indicator on the Leaderboard support Scoring Code downloads. You can download Scoring Code JARs from the Leaderboard or from a deployment.


The model JAR files require Java 8 or later.

See below for examples of:

  • Using the binary Scoring Code JAR to score a CSV file on the command line.
  • Using the downloaded JAR in a Java project.

Command line interface example

The following example uses the binary scoring code JAR to score a CSV file. See Scoring with the embedded CLI for complete syntax.

java -Dlog4j2.formatMsgNoLookups=true -jar 5cd071deef881f011a334c2f.jar csv --input=Iris.csv --output=Isis_out.csv


    head Iris_out.csv

See also descriptions of command line parameters and increasing Java heap memory.

Java API example

To be used with the Java API, add the downloaded JAR file to the classpath of the Java project. This API has different output formats for regression and classification projects. Below is an example of both:

    import com.datarobot.prediction.IClassificationPredictor;
    import com.datarobot.prediction.IRegressionPredictor;
    import com.datarobot.prediction.Predictors;

    import java.util.HashMap;
    import java.util.Map;

    public class Main {

       public static void main(String[] args) {
          // data is being passed as a Java map
          Map<String, Object> row = new HashMap<>();
          row.put("a", 1);
          row.put("b", "some string feature");
          row.put("c", 999);

          // below is an example of prediction of a single variable (regression)

          // model id is the name of the .jar file
          String regression_modelId = "5d2db3e5bad451002ac53318";

          // get a regression predictor object given model
          IRegressionPredictor regression_predictor =

          double scored_value = regression_predictor.score(row);

          System.out.println("The predicted variable: " + scored_value);

          // below is an example of prediction of class probabilities (classification)

          // model id is the name of the .jar file
          String classification_modelId = "5d36ee03962d7429f0a6be72";

          // get a classification predictor object given model
          IClassificationPredictor predictor =

          Map<String, Double> class_probabilities = predictor.score(row);

          for (String class_label : class_probabilities.keySet()) {
             System.out.println(String.format("The probability of the row belonging to class %s is %f",
                class_label, class_probabilities.get(class_label)));

See also a backward-compatibility example for use when models are generated by different versions of DataRobot.

Updated May 31, 2022
Back to top