Generates predictions for a group of observations. The observations to process exist in one or more data files referenced by a DataSource. This operation creates a new BatchPrediction, and uses an MLModel and the data files referenced by the DataSource as information sources.
CreateBatchPrediction is an asynchronous operation. In response to CreateBatchPrediction, Amazon Machine Learning (Amazon ML) immediately returns and sets the BatchPrediction status to PENDING. After the BatchPrediction completes, Amazon ML sets the status to COMPLETED.
You can poll for status updates by using the GetBatchPrediction operation and checking the Status parameter of the result. After the COMPLETED status appears, the results are available in the location specified by the OutputUri parameter.
Parameters:
-
batch_prediction_id
(EntityId)
–
A user-supplied ID that uniquely identifies the BatchPrediction.
-
batch_prediction_name
(Optional[EntityName], default:
None
)
–
A user-supplied name or description of the BatchPrediction. BatchPredictionName can only use the UTF-8 character set.
-
ml_model_id
(EntityId)
–
The ID of the MLModel that will generate predictions for the group of observations.
-
batch_prediction_data_source_id
(EntityId)
–
The ID of the DataSource that points to the group of observations to predict.
-
output_uri
(S3Url)
–
The location of an Amazon Simple Storage Service (Amazon S3) bucket or directory to store the batch prediction results. The following substrings are not allowed in the s3 key portion of the outputURI field: ':', '//', '/./', '/../'.
Amazon ML needs permissions to store and retrieve the logs on your behalf. For information about how to set permissions, see the Amazon Machine Learning Developer Guide.
Raises:
Source code in docs_src/capo_machine_learning/_services/async_machine_learning.py
| async def create_batch_prediction(
self,
batch_prediction_id: "capo_machine_learning.types.entity_id.EntityId",
ml_model_id: "capo_machine_learning.types.entity_id.EntityId",
batch_prediction_data_source_id: "capo_machine_learning.types.entity_id.EntityId",
output_uri: "capo_machine_learning.types.s3_url.S3Url",
*,
config_overrides: Optional[AsyncMachineLearningClientConfig] = None,
batch_prediction_name: Optional[
"capo_machine_learning.types.entity_name.EntityName"
] = None,
) -> "capo_machine_learning.types.create_batch_prediction_output.CreateBatchPredictionOutput":
"""<p>Generates predictions for a group of observations. The observations to process exist in one or more data files referenced by a <code>DataSource</code>. This operation creates a new <code>BatchPrediction</code>, and uses an <code>MLModel</code> and the data files referenced by the <code>DataSource</code> as information sources. </p> <p> <code>CreateBatchPrediction</code> is an asynchronous operation. In response to <code>CreateBatchPrediction</code>, Amazon Machine Learning (Amazon ML) immediately returns and sets the <code>BatchPrediction</code> status to <code>PENDING</code>. After the <code>BatchPrediction</code> completes, Amazon ML sets the status to <code>COMPLETED</code>. </p> <p>You can poll for status updates by using the <a>GetBatchPrediction</a> operation and checking the <code>Status</code> parameter of the result. After the <code>COMPLETED</code> status appears, the results are available in the location specified by the <code>OutputUri</code> parameter.</p>
Args:
batch_prediction_id: <p>A user-supplied ID that uniquely identifies the <code>BatchPrediction</code>.</p>
batch_prediction_name: <p>A user-supplied name or description of the <code>BatchPrediction</code>. <code>BatchPredictionName</code> can only use the UTF-8 character set.</p>
ml_model_id: <p>The ID of the <code>MLModel</code> that will generate predictions for the group of observations. </p>
batch_prediction_data_source_id: <p>The ID of the <code>DataSource</code> that points to the group of observations to predict.</p>
output_uri: <p>The location of an Amazon Simple Storage Service (Amazon S3) bucket or directory to store the batch prediction results. The following substrings are not allowed in the <code>s3 key</code> portion of the <code>outputURI</code> field: ':', '//', '/./', '/../'.</p> <p>Amazon ML needs permissions to store and retrieve the logs on your behalf. For information about how to set permissions, see the <a href="https://docs.aws.amazon.com/machine-learning/latest/dg">Amazon Machine Learning Developer Guide</a>.</p>
Raises:
capo_machine_learning.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>A second request to use or change an object was not allowed. This can result from retrying a request using a parameter that was not present in the original request.</p>
capo_machine_learning.errors.internal_server_exception.InternalServerException: <p>An error on the server occurred when trying to process a request.</p>
capo_machine_learning.errors.invalid_input_exception.InvalidInputException: <p>An error on the client occurred. Typically, the cause is an invalid input value.</p>
capo_machine_learning.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_machine_learning.types.create_batch_prediction_input.CreateBatchPredictionInput]",
) -> AsyncOperationResponse[
"capo_machine_learning.types.create_batch_prediction_output.CreateBatchPredictionOutput"
]:
import capo_machine_learning._operations.amazon_ml_20141212.create_batch_prediction
(
output,
http_response,
) = await capo_machine_learning._operations.amazon_ml_20141212.create_batch_prediction.async_create_batch_prediction(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateBatchPrediction")
)
input_: capo_machine_learning.types.create_batch_prediction_input.CreateBatchPredictionInput = {
"batch_prediction_id": batch_prediction_id,
"ml_model_id": ml_model_id,
"batch_prediction_data_source_id": batch_prediction_data_source_id,
"output_uri": output_uri,
}
if batch_prediction_name is not None:
input_["batch_prediction_name"] = batch_prediction_name
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|