Make real-time predictions against SageMaker endpoints with Python objects
RealTimePredictor(endpoint, sagemaker_session=None, serializer=None, deserializer=None, content_type=None, accept=None)¶
Make prediction requests to an Amazon SageMaker endpoint.
Behavior for serialization of input data and deserialization of result data can be configured through initializer arguments. If not specified, a sequence of bytes is expected and the API sends it in the request body without modifications. In response, the API returns the sequence of bytes from the prediction result without any modifications.
- endpoint (str) – Name of the Amazon SageMaker endpoint to which requests are sent.
- sagemaker_session (sagemaker.session.Session) – A SageMaker Session object, used for SageMaker interactions (default: None). If not specified, one is created using the default AWS configuration chain.
- serializer (callable) – Accepts a single argument, the input data,
and returns a sequence of bytes. It may provide a
content_typeattribute that defines the endpoint request content type. If not specified, a sequence of bytes is expected for the data.
- deserializer (callable) – Accepts two arguments, the result data and
the response content type, and returns a sequence of bytes. It
may provide a
content_typeattribute that defines the endpoint response’s “Accept” content type. If not specified, a sequence of bytes is expected for the data.
- content_type (str) – The invocation’s “ContentType”, overriding any
content_typefrom the serializer (default: None).
- accept (str) – The invocation’s “Accept”, overriding any accept from the deserializer (default: None).
Return the inference from the specified endpoint.
- data (object) – Input data for which you want the model to provide inference. If a serializer was specified when creating the RealTimePredictor, the result of the serializer is sent as input data. Otherwise the data must be sequence of bytes, and the predict method then sends the bytes in the request body as is.
- initial_args (dict[str,str]) – Optional. Default arguments for boto3
invoke_endpointcall. Default is None (no default arguments).
- Inference for the given input. If a deserializer was specified when creating
the RealTimePredictor, the result of the deserializer is returned. Otherwise the response returns the sequence of bytes as is.
Delete the Amazon SageMaker endpoint backing this predictor. Also delete the endpoint configuration attached to it if delete_endpoint_config is True.
Parameters: delete_endpoint_config (bool, optional) – Flag to indicate whether to delete endpoint configuration together with endpoint. Defaults to True. If True, both endpoint and endpoint configuration will be deleted. If False, only endpoint will be deleted.
Deletes the Amazon SageMaker models backing this predictor.
Updates the DataCaptureConfig for the Predictor’s associated Amazon SageMaker Endpoint to enable data capture. For a more customized experience, refer to update_data_capture_config, instead.
Updates the DataCaptureConfig for the Predictor’s associated Amazon SageMaker Endpoint to disable data capture. For a more customized experience, refer to update_data_capture_config, instead.
Updates the DataCaptureConfig for the Predictor’s associated Amazon SageMaker Endpoint with the provided DataCaptureConfig.
Parameters: data_capture_config (sagemaker.model_monitor.DataCaptureConfig) – The DataCaptureConfig to update the predictor’s endpoint to use.
Generates ModelMonitor objects (or DefaultModelMonitors) based on the schedule(s) associated with the endpoint that this predictor refers to.
Returns: A list of ModelMonitor (or DefaultModelMonitor) objects. Return type: [ModelMonitor]