Skip to content

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

Quickstart

Availability information

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

Models displaying the SCORING CODE icon on the Leaderboard are available for scoring code download. Navigate to the Predict > Downloads tab, where you can select a download option and access a link to the up-to-date model API documentation.

Note

The model JAR files require Java 8 or later.

See below for:

Command line interface

Following is complete syntax for using the binary scoring code JAR to score a .csv file:

 $ java -jar .jar csv --input= --output= [--help] [--encoding=] [--delimiter=]
 [--passthrough_columns=] [--chunk_size=] [--workers_number=] [--log_level=]
 [--fail_fast] [--pred_name=] [--timeout=] [--buffer_size=] [--model_id=]
 [--config=]

For example:

$ java -jar 5cd071deef881f011a334c2f.jar csv --input=Iris.csv --output=Isis_out.csv

Returns:

$ head Iris_out.csv
Iris-setosa,Iris-virginica,Iris-versicolor
0.9996371740832738,1.8977798830979584E-4,1.7304792841625776E-4
0.9996352462865297,1.9170611877686303E-4,1.730475946939417E-4
0.9996373523223016,1.8970270284380858E-4,1.729449748545291E-4

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 =
         Predictors.getPredictor(regression_modelId);

      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 =
         Predictors.getPredictor(classification_modelId);

      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 October 27, 2021
Back to top