logValidationRecords

Overview

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:

API

<T> Response logValidationRecords(
   final String modelId, 
   final String modelVersion,
   final String batchId,
   final List<Map<String, ?>> features,
   final List<Map<String, ?>> tags,
   final List<Map<String, Embedding>> embeddingFeatures,
   final List<T> predictionLabels,
   final List<T> actualLabels,
   final List<Long> predictionTimestamps) throws IOException, IllegalArgumentException; 

API arguments

Sample Code

import com.arize.ArizeClient;
import com.arize.Response;

final ArizeClient arize = new ArizeClient(System.getenv("ARIZE_API_KEY"), System.getenv("ARIZE_SPACE_KEY"));

final List<Map<String, ?>> features = new ArrayList<Map<String, ?>>();
features.add(new HashMap<String, Object>() {{ put("days", 5); put("is_organic", 1);}});
features.add(new HashMap<String, Object>() {{ put("days", 3); put("is_organic", 0);}});
features.add(new HashMap<String, Object>() {{ put("days", 7); put("is_organic", 0);}});

final List<Map<String, Embedding>> embeddingFeatures = new ArrayList<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"));}});

final List<Map<String, ?>> tags = new ArrayList<Map<String, ?>>();
tags.add(new HashMap<String, Object>() {{ put("metadata", 5); put("my business metric", 1);}});
tags.add(new HashMap<String, Object>() {{ put("metadata", 3); put("my business metric", 0);}});
tags.add(new HashMap<String, Object>() {{ put("metadata", 7); put("my business metric", 8);}});

final List<String> predictionLabels = new ArrayList<String>(Arrays.asList("pear", "banana", "apple"));
final List<String> actualLabels = new ArrayList<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 successful
switch (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 correct
        break;
    case BAD_REQUEST:
        // TODO: Malformed request
        System.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 URI
        break;
    case UNEXPECTED_FAILURE:
        // TODO: Unexpected failure, check for a reason on response body
        System.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");

Questions? Email us at support@arize.com or Slack us in the #arize-support channel

Last updated

Copyright © 2023 Arize AI, Inc