Use the initialized Arize client to call arize.logValidationrecords() with collections of predicted and actual labels, its feature inputs, and corresponding prediction ids for a specific named batch. Once records are sent to Arize's platform, you'll be able to visualize and analyze data holistically or within aggregated slices and use this data to compare against your production and training results or use it as baseline data for monitoring your model.
arize.logValidationRecords() returns a Response. You can await on the Response to complete to ensure successful delivery of records.
When logging a prediction for the first time for a new model, we classify the model in the Arize platform based on the data type of the prediction.
For more information on model schema discovery, visit here:
importcom.arize.ArizeClient;importcom.arize.Response;finalArizeClient arize =newArizeClient(System.getenv("ARIZE_API_KEY"),System.getenv("ARIZE_SPACE_KEY"));finalList<Map<String,?>> features =newArrayList<Map<String,?>>();features.add(newHashMap<String,Object>() {{ put("days",5); put("is_organic",1);}});features.add(newHashMap<String,Object>() {{ put("days",3); put("is_organic",0);}});features.add(newHashMap<String,Object>() {{ put("days",7); put("is_organic",0);}});finalList<Map<String,Embedding>> embeddingFeatures =newArrayList<Map<String,Embedding>>();embeddingFeatures.add(new HashMap<String, Embedding>() {{ put("embedding_feature_1", new Embedding(Arrays.asList(1.0, 0.5), Arrays.asList("test", "token", "array"), "https://example.com/image.jpg")); put("embedding_feature_2", new Embedding(Arrays.asList(1.0, 0.8), Arrays.asList("this", "is"), "https://example.com/image_3.jpg"));}});
embeddingFeatures.add(new HashMap<String, Embedding>() {{ put("embedding_feature_1", new Embedding(Arrays.asList(0.0, 0.6), Arrays.asList("another", "example"), "https://example.com/image_2.jpg")); put("embedding_feature_2", new Embedding(Arrays.asList(0.1, 1.0), Arrays.asList("an", "example"), "https://example.com/image_4.jpg"));}});
embeddingFeatures.add(new HashMap<String, Embedding>() {{ put("embedding_feature_1", new Embedding(Arrays.asList(1.0, 0.8), Arrays.asList("third"), "https://example.com/image_3.jpg")); put("embedding_feature_2", new Embedding(Arrays.asList(1.0, 0.4), Arrays.asList("token", "array"), "https://example.com/image_5.jpg"));}});
finalList<Map<String,?>> tags =newArrayList<Map<String,?>>();tags.add(newHashMap<String,Object>() {{ put("metadata",5); put("my business metric",1);}});tags.add(newHashMap<String,Object>() {{ put("metadata",3); put("my business metric",0);}});tags.add(newHashMap<String,Object>() {{ put("metadata",7); put("my business metric",8);}});finalList<String> predictionLabels =newArrayList<String>(Arrays.asList("pear","banana","apple"));finalList<String> actualLabels =newArrayList<String>(Arrays.asList("pear","strawberry","apple"));final Response asyncResponse = arize.logTrainingRecords("exampleModelId", "v1", "offline-batch", features, embeddingFeatures, tags, predictionLabels, actualLabels);
// This is a blocking call similar to future.get()asyncResponse.resolve();// Check that the API call was successfulswitch (asyncResponse.getResponseCode()) {case OK:// TODO: Success!System.out.println("Success!!!");break;case AUTHENTICATION_ERROR:// TODO: Check to make sure your Arize API KEY and Space key are correctbreak;case BAD_REQUEST:// TODO: Malformed requestSystem.out.println("Failure Reason: "+asyncResponse.getResponseBody());case NOT_FOUND:// TODO: API endpoint not found, client is likely malconfigured, make sure you// are not overwriting Arize's endpoint URIbreak;case UNEXPECTED_FAILURE:// TODO: Unexpected failure, check for a reason on response bodySystem.out.println("Failure Reason: "+asyncResponse.getResponseBody());break;}System.out.println("Response Code: "+asyncResponse.getResponseCode());System.out.println("Response Body: "+asyncResponse.getResponseBody());// Don't forget to shutdown the client with your application shutdown hook.arize.close();System.out.println("Done");
Used to group together a subset of predictions and actuals for a given model_id.
Required
batchId
String
Used to group together a subset of records for a given model_id and model_version.
Required
features
List<Map<String, ?>>
Where value can be oneOf: String, int, long, short, double, float, boolean, List<String>
List of Maps containing human readable and debuggable model features. Keys must be Strings and values one of: String, int, long, short, double, float, boolean, List<String>
Optional
embeddingFeatures
Map<String, Embedding>
Map containing human readable and debuggable model embedding features. Map keys must be String and values Embedding
Optional
tags
Map<String, ?> Where value can be oneOf: String, int, long, short, double, float, boolean, List<String>
Map containing human readable and debuggable model features. Map keys must be String and values one of: String, int, long, short, double, float, boolean, List<String>
Optional
predictionLabels
List<T> where T is oneof String, boolean, int, long, short, float, double, ScoreCategorical
The predicted labels for your given model inputs contained in a List<T>
Important: If sent in as an argument, entries are matched respectively to the entries in prediction ids, feature values, and feature importances in the same index.
Important: Must have the same number of elements as feature, actuals, and importances is all sent together.
Required
actualLabels
List<T> where T is oneof String, boolean, int, long, short, float, double, ScoreCategorical
The actual observed labels for a given model input.
Important: If passed together in a single call with predictionLabels, both inputs must have the same shape.
Important: If model is Score Categorical, Arize.ScoreCategorical object should be passed in with corresponding predictedLabel, probabilityScore.