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.