Skip to content

create_metric_attribution

create_metric_attribution(
    name: Name,
    dataset_group_arn: Arn,
    metrics: MetricAttributes,
    metrics_output_config: MetricAttributionOutput,
    *,
    config_overrides: Optional[PersonalizeClientConfig] = None,
) -> CreateMetricAttributionResponse

Creates a metric attribution. A metric attribution creates reports on the data that you import into Amazon Personalize. Depending on how you imported the data, you can view reports in Amazon CloudWatch or Amazon S3. For more information, see Measuring impact of recommendations.

Parameters:

  • name (Name) –

    A name for the metric attribution.

  • dataset_group_arn (Arn) –

    The Amazon Resource Name (ARN) of the destination dataset group for the metric attribution.

  • metrics (MetricAttributes) –

    A list of metric attributes for the metric attribution. Each metric attribute specifies an event type to track and a function. Available functions are SUM() or SAMPLECOUNT(). For SUM() functions, provide the dataset type (either Interactions or Items) and column to sum as a parameter. For example SUM(Items.PRICE).

  • metrics_output_config (MetricAttributionOutput) –

    The output configuration details for the metric attribution.

Raises:

Source code in docs_src/capo_personalize/_services/personalize.py
def create_metric_attribution(
    self,
    name: "capo_personalize.types.name.Name",
    dataset_group_arn: "capo_personalize.types.arn.Arn",
    metrics: "capo_personalize.types.metric_attributes.MetricAttributes",
    metrics_output_config: "capo_personalize.types.metric_attribution_output.MetricAttributionOutput",
    *,
    config_overrides: Optional[PersonalizeClientConfig] = None,
) -> "capo_personalize.types.create_metric_attribution_response.CreateMetricAttributionResponse":
    """<p>Creates a metric attribution. A metric attribution creates reports on the data that you import into Amazon Personalize. Depending on how you imported the data, you can view reports in Amazon CloudWatch or Amazon S3. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/measuring-recommendation-impact.html">Measuring impact of recommendations</a>.</p>

    Args:
        name: <p>A name for the metric attribution.</p>
        dataset_group_arn: <p>The Amazon Resource Name (ARN) of the destination dataset group for the metric attribution.</p>
        metrics: <p>A list of metric attributes for the metric attribution. Each metric attribute specifies an event type to track and a function. Available functions are <code>SUM()</code> or <code>SAMPLECOUNT()</code>. For SUM() functions, provide the dataset type (either Interactions or Items) and column to sum as a parameter. For example SUM(Items.PRICE).</p>
        metrics_output_config: <p>The output configuration details for the metric attribution.</p>

    Raises:
        capo_personalize.errors.invalid_input_exception.InvalidInputException: <p>Provide a valid value for the field or parameter.</p>
        capo_personalize.errors.limit_exceeded_exception.LimitExceededException: <p>The limit on the number of requests per second has been exceeded.</p>
        capo_personalize.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The specified resource already exists.</p>
        capo_personalize.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource is in use.</p>
        capo_personalize.errors.resource_not_found_exception.ResourceNotFoundException: <p>Could not find the specified resource.</p>
        capo_personalize.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_personalize.types.create_metric_attribution_request.CreateMetricAttributionRequest]",
    ) -> OperationResponse[
        "capo_personalize.types.create_metric_attribution_response.CreateMetricAttributionResponse"
    ]:
        import capo_personalize._operations.amazon_personalize.create_metric_attribution

        output, http_response = (
            capo_personalize._operations.amazon_personalize.create_metric_attribution.create_metric_attribution(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateMetricAttribution")
    )
    input_: capo_personalize.types.create_metric_attribution_request.CreateMetricAttributionRequest = {
        "name": name,
        "dataset_group_arn": dataset_group_arn,
        "metrics": metrics,
        "metrics_output_config": metrics_output_config,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output