Package com.arize

Class ArizeClient

    • Constructor Detail

      • ArizeClient

        @Deprecated
        public ArizeClient​(org.apache.http.impl.nio.client.CloseableHttpAsyncClient client,
                           String apiKey,
                           String spaceKey,
                           String uri)
                    throws URISyntaxException
        Deprecated.
        use ArizeClient.ClientBuilder instead. For example:
        
         ArizeClient client = new ArizeClient.ClientBuilder()
             .httpClient(httpClient)
             .apiKey(apiKey)
             .SpaceId(SpaceId)
             .uri(uri)
             .build();
         
        Constructor for passing in an httpClient, typically for mocking.
        Parameters:
        client - an Apache CloseableHttpAsyncClient
        uri - uri for Arize endpoint
        Throws:
        URISyntaxException - if uri string violates RFC 2396
      • ArizeClient

        @Deprecated
        public ArizeClient​(String apiKey,
                           String spaceKey)
                    throws URISyntaxException
        Deprecated.
        use ArizeClient.ClientBuilder instead. For example:
        
         ArizeClient client = new ArizeClient.ClientBuilder()
             .apiKey(apiKey)
             .SpaceId(SpaceId)
             .build();
         
        Construct a new API wrapper.
        Parameters:
        apiKey - your Arize API Key
        spaceKey - your Arize space key
        Throws:
        URISyntaxException - if uri string violates RFC 2396
      • ArizeClient

        @Deprecated
        public ArizeClient​(String apiKey,
                           String spaceKey,
                           String uri)
                    throws URISyntaxException
        Deprecated.
        use ArizeClient.ClientBuilder instead. For example:
        
         ArizeClient client = new ArizeClient.ClientBuilder()
             .apiKey(apiKey)
             .SpaceId(SpaceId)
             .uri(uri)
             .build();
         
        Construct a new API wrapper while overwriting the Arize endpoint, typically for custom integrations and e2e testing.
        Parameters:
        apiKey - your Arize API Key
        spaceKey - your Arize space key
        uri - uri for Arize endpoint
        Throws:
        URISyntaxException - if uri string violates RFC 2396
    • Method Detail

      • buildRequest

        protected static org.apache.http.client.methods.HttpPost buildRequest​(String body,
                                                                              URI host,
                                                                              String apiKey,
                                                                              String spaceKey,
                                                                              String spaceId)
      • getHost

        public URI getHost()
        Get the host.
        Returns:
        the host
      • getSpaceKey

        public String getSpaceKey()
        Get the space key in the Arize platform
        Returns:
        the Arize supplied space key
      • log

        public <T> Response log​(String modelId,
                                String modelVersion,
                                String predictionId,
                                Map<String,​?> features,
                                Map<String,​Embedding> embeddingFeatures,
                                Map<String,​?> tags,
                                T predictionLabel,
                                T actualLabel,
                                Map<String,​Double> shapValues,
                                long predictionTimestamp)
                         throws IOException,
                                IllegalArgumentException
        log builds and submits a record to the Arize API.

        log constructs a record and executes the API call asynchronously returning a future.

        Specified by:
        log in interface ArizeAPI
        Type Parameters:
        T - Boxed type for predictionLabel. Supported boxed types are: boolean, string, int, long, short, float, double.
        Parameters:
        modelId - Unique identifier for a given model.
        modelVersion - Model version identifier used to group together a subset of predictions and actuals for a given modelId.
        predictionId - Required unique identifier for a given prediction.
        features - Optional Map containing model features. Map key must be String and values are one of: string, int, long, short, float, double, boolean.
        embeddingFeatures - Optional Map containing model embedding features. Map key must be String and values Embedding
        tags - Optional Map containing record tags (aka metadata) that can be associated with a prediction. This can be used to filter during analysis. Map key must be String and values are one of: string, int, long, short, float, double, boolean. by non-feature data.
        predictionLabel - Predicted value for a given set of model inputs. Supported boxed types are: boolean, string, int, long, short, float, double. Not required if sending latent actual or feature importance.
        actualLabel - The latent truth value for a given set of model inputs. Supported boxed types are: boolean, string, int, long, short, float, double. This can either be supplied at the same time as the predictionLabel or on its own once it is known, and it will be linked back by the predictionId
        shapValues - Optional Map from feature name to shap value. This can either be supplied at the same time as the predictionLabel or on its own, and it will be linked back by the predictionId
        predictionTimestamp - The timestamp to which the prediction should be attributed. If not set this defaults to the time of receipt
        Returns:
        Response
        Throws:
        IOException - in case of a network error
        IllegalArgumentException - in case data type for features or label are not supported.
      • bulkLog

        public <T> Response bulkLog​(String modelId,
                                    String modelVersion,
                                    List<String> predictionIds,
                                    List<Map<String,​?>> features,
                                    List<Map<String,​Embedding>> embeddingFeatures,
                                    List<Map<String,​?>> tags,
                                    List<T> predictionLabels,
                                    List<T> actualLabels,
                                    List<Map<String,​Double>> shapValues,
                                    List<Long> predictionTimestamps)
                             throws IOException,
                                    IllegalArgumentException
        logBulkPrediction builds and submits a Bulk Prediction record to the Arize API.

        bulkLog constructs a bulk record and executes the API call asynchronously returning a future response.

        Specified by:
        bulkLog in interface ArizeAPI
        Type Parameters:
        T - Boxed type for predictionLabel and actualLabel. Supported boxed types are: boolean, string, int, long, short, float, double.
        Parameters:
        modelId - Unique String identifier for a given model.
        modelVersion - Optional String identifier used to group together a subset of predictions and actuals for a given modelId.
        predictionIds - List of unique String indentifiers for predictions. This value is used to match latent actual labels to their original predictions.
        features - Optional List of Map varargs containing human-readable and debuggable model features. Map key must be String and values are one of: string, int, long, short, float, double, boolean.
        embeddingFeatures - Optional List of Map varargs containing human-readable and debuggable model embedding features. Map key must be String and values Embedding.
        tags - Optional List of Map varargs containing record tags/metadata. Map key must be String and values are one of: string, int, long, short, float, double, boolean.
        predictionLabels - List of predicted values. Supported boxed types are: boolean, string, int, long, short, float, double.
        actualLabels - List of latent actual values. Supported boxed types are: boolean, string, int, long, short, float, double. This can either be supplied at the same time as the predictionLabels or on their own once they are known, and they will be linked back by the corresponding predictionIds
        shapValues - Optional List of Map from feature name to shap value. Can be provided at the same time as the predictionLabels or on their own and they will be linked back by the corresponding predictionIds
        predictionTimestamps - Optional List of Long of unix epoch time in milliseconds used to overwrite timestamp for a prediction.
        Returns:
        Response
        Throws:
        IOException - in case of a network error
        IllegalArgumentException - in case data type for features or label are not supported.
      • logTrainingRecords

        public <T> Response logTrainingRecords​(String modelId,
                                               String modelVersion,
                                               List<Map<String,​?>> features,
                                               List<Map<String,​Embedding>> embeddingFeatures,
                                               List<Map<String,​?>> tags,
                                               List<T> predictionLabels,
                                               List<T> actualLabels)
                                        throws IOException
        Specified by:
        logTrainingRecords in interface ArizeAPI
        Type Parameters:
        T - Boxed type for predictionLabel and actualLabel. Supported boxed types are: boolean, string, int, long, short, float, double.
        Parameters:
        modelId - Unique String identifier for a given model.
        modelVersion - Optional String identifier used to group together a subset of predictions and actuals for a given modelId.
        features - Optional List of Map varargs containing human-readable and debuggable model features. Map key must be String and values are one of: string, int, long, short, float, double, boolean.
        embeddingFeatures - Optional List of Map varargs containing human-readable and debuggable model embedding features. Map key must be String and values Embedding.
        tags - Optional List of Map varargs containing record tags/metadata. Map key must be String and values are one of: string, int, long, short, float, double, boolean.
        predictionLabels - List of predicted values. Supported boxed types are: boolean, string, int, long, short, float, double.
        actualLabels - List of latent actual values. Supported boxed types are: boolean, string, int, long, short, float, double. This can either be supplied at the same time as the predictionLabels or on their own once they are known, and they will be linked back by the corresponding predictionIds
        Returns:
        Response
        Throws:
        IOException - in case of a network error
      • logValidationRecords

        public <T> Response logValidationRecords​(String modelId,
                                                 String modelVersion,
                                                 String batchId,
                                                 List<Map<String,​?>> features,
                                                 List<Map<String,​Embedding>> embeddingFeatures,
                                                 List<Map<String,​?>> tags,
                                                 List<T> predictionLabels,
                                                 List<T> actualLabels)
                                          throws IOException
        Specified by:
        logValidationRecords in interface ArizeAPI
        Type Parameters:
        T - Boxed type for predictionLabel and actualLabel. Supported boxed types are: boolean, string, int, long, short, float, double.
        Parameters:
        modelId - Unique String identifier for a given model.
        modelVersion - Optional String identifier used to group together a subset of predictions and actuals for a given modelId.
        batchId - Unique identifier for the validation batch we are adding data to
        features - Optional List of Map varargs containing human readable and debuggable model features. Map key must be String and values are one of: string, int, long, short, float, double, boolean.
        embeddingFeatures - Optional List of Map varargs containing human-readable and debuggable model embedding features. Map key must be String and values Embedding.
        tags - Optional List of Map varargs containing record tags/metadata. Map key must be String and values are one of: string, int, long, short, float, double, boolean.
        predictionLabels - List of predicted values. Supported boxed types are: boolean, string, int, long, short, float, double.
        actualLabels - List of latent actual values. Supported boxed types are: boolean, string, int, long, short, float, double. This can either be supplied at the same time as the predictionLabels or on their own once they are known, and they will be linked back by the corresponding predictionIds
        Returns:
        Response
        Throws:
        IOException - in case of a network error
      • close

        public void close()
                   throws IOException
        Closes the http client.
        Throws:
        IOException - in case of a network error