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.
Java requirement
The MLOps monitoring library requires Java 11 or higher. Without monitoring, a model's Scoring Code JAR file requires Java 8 or higher; however, when using the MLOps library to instrument monitoring, a model's Scoring Code JAR file requires Java 11 or higher. For Self-managed AI platform installations, the Java 11 requirement applies to DataRobot v11.0 and higher.
See below for examples of:
Using the binary Scoring Code JAR to score a CSV file on the command line.
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:
importcom.datarobot.prediction.IClassificationPredictor;importcom.datarobot.prediction.IRegressionPredictor;importcom.datarobot.prediction.Predictors;importjava.util.HashMap;importjava.util.Map;publicclassMain{publicstaticvoidmain(String[]args){Map<String,Object>row=newHashMap<>();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)// get a regression predictor by model idIRegressionPredictorregressionPredictor=Predictors.getPredictor("5d2db3e5bad451002ac53318");doublescored_value=regressionPredictor.score(row);System.out.println("The predicted variable: "+scored_value);// below is an example of prediction of class probabilities (classification)// get a regression predictor by model idIClassificationPredictorpredictor=Predictors.getPredictor("5d36ee03962d7429f0a6be72");Map<String,Double>classProbabilities=predictor.score(row);for(Stringclass_label:classProbabilities.keySet()){System.out.printf("The probability of the row belonging to class %s is %f%n",class_label,classProbabilities.get(class_label));}}}
See also a backward-compatibility example for use when models are generated by different versions of DataRobot.
Including model JAR files in the Java class path can result in conflicts between the dependencies in the model JAR file and those in the application code or other model JAR files. To avoid these conflicts, you can load models from the filesystem at runtime using Predictors.getPredictorFromJarFile():
When you download a Scoring Code JAR from the Leaderboard or from a deployment with Include Prediction Explanations enabled, you can calculate Prediction Explanations in your Java code.