Skip to content

create_explainability

create_explainability(
    explainability_name: Name,
    resource_arn: Arn,
    explainability_config: ExplainabilityConfig,
    *,
    config_overrides: Optional[forecastClientConfig] = None,
    data_source: Optional[DataSource] = None,
    schema: Optional[Schema] = None,
    enable_visualization: Optional[Boolean] = None,
    start_date_time: Optional[LocalDateTime] = None,
    end_date_time: Optional[LocalDateTime] = None,
    tags: Optional[Tags] = None,
) -> CreateExplainabilityResponse

Explainability is only available for Forecasts and Predictors generated from an AutoPredictor (CreateAutoPredictor)

Creates an Amazon Forecast Explainability.

Explainability helps you better understand how the attributes in your datasets impact forecast. Amazon Forecast uses a metric called Impact scores to quantify the relative impact of each attribute and determine whether they increase or decrease forecast values.

To enable Forecast Explainability, your predictor must include at least one of the following: related time series, item metadata, or additional datasets like Holidays and the Weather Index.

CreateExplainability accepts either a Predictor ARN or Forecast ARN. To receive aggregated Impact scores for all time series and time points in your datasets, provide a Predictor ARN. To receive Impact scores for specific time series and time points, provide a Forecast ARN.

CreateExplainability with a Predictor ARN

You can only have one Explainability resource per predictor. If you already enabled ExplainPredictor in CreateAutoPredictor, that predictor already has an Explainability resource.

The following parameters are required when providing a Predictor ARN:

  • ExplainabilityName - A unique name for the Explainability.

  • ResourceArn - The Arn of the predictor.

  • TimePointGranularity - Must be set to “ALL”.

  • TimeSeriesGranularity - Must be set to “ALL”.

Do not specify a value for the following parameters:

  • DataSource - Only valid when TimeSeriesGranularity is “SPECIFIC”.

  • Schema - Only valid when TimeSeriesGranularity is “SPECIFIC”.

  • StartDateTime - Only valid when TimePointGranularity is “SPECIFIC”.

  • EndDateTime - Only valid when TimePointGranularity is “SPECIFIC”.

CreateExplainability with a Forecast ARN

You can specify a maximum of 50 time series and 500 time points.

The following parameters are required when providing a Predictor ARN:

  • ExplainabilityName - A unique name for the Explainability.

  • ResourceArn - The Arn of the forecast.

  • TimePointGranularity - Either “ALL” or “SPECIFIC”.

  • TimeSeriesGranularity - Either “ALL” or “SPECIFIC”.

If you set TimeSeriesGranularity to “SPECIFIC”, you must also provide the following:

  • DataSource - The S3 location of the CSV file specifying your time series.

  • Schema - The Schema defines the attributes and attribute types listed in the Data Source.

If you set TimePointGranularity to “SPECIFIC”, you must also provide the following:

  • StartDateTime - The first timestamp in the range of time points.

  • EndDateTime - The last timestamp in the range of time points.

Parameters:

  • explainability_name (Name) –

    A unique name for the Explainability.

  • resource_arn (Arn) –

    The Amazon Resource Name (ARN) of the Predictor or Forecast used to create the Explainability.

  • explainability_config (ExplainabilityConfig) –

    The configuration settings that define the granularity of time series and time points for the Explainability.

  • enable_visualization (Optional[Boolean], default: None ) –

    Create an Explainability visualization that is viewable within the Amazon Web Services console.

  • start_date_time (Optional[LocalDateTime], default: None ) –

    If TimePointGranularity is set to SPECIFIC, define the first point for the Explainability.

    Use the following timestamp format: yyyy-MM-ddTHH:mm:ss (example: 2015-01-01T20:00:00)

  • end_date_time (Optional[LocalDateTime], default: None ) –

    If TimePointGranularity is set to SPECIFIC, define the last time point for the Explainability.

    Use the following timestamp format: yyyy-MM-ddTHH:mm:ss (example: 2015-01-01T20:00:00)

  • tags (Optional[Tags], default: None ) –

    Optional metadata to help you categorize and organize your resources. Each tag consists of a key and an optional value, both of which you define. Tag keys and values are case sensitive.

    The following restrictions apply to tags:

    • For each resource, each tag key must be unique and each tag key must have one value.

    • Maximum number of tags per resource: 50.

    • Maximum key length: 128 Unicode characters in UTF-8.

    • Maximum value length: 256 Unicode characters in UTF-8.

    • Accepted characters: all letters and numbers, spaces representable in UTF-8, and + - = . _ : / @. If your tagging schema is used across other services and resources, the character restrictions of those services also apply.

    • Key prefixes cannot include any upper or lowercase combination of aws: or AWS:. Values can have this prefix. If a tag value has aws as its prefix but the key does not, Forecast considers it to be a user tag and will count against the limit of 50 tags. Tags with only the key prefix of aws do not count against your tags per resource limit. You cannot edit or delete tag keys with this prefix.

Raises:

Source code in docs_src/capo_forecast/_services/forecast.py
def create_explainability(
    self,
    explainability_name: "capo_forecast.types.name.Name",
    resource_arn: "capo_forecast.types.arn.Arn",
    explainability_config: "capo_forecast.types.explainability_config.ExplainabilityConfig",
    *,
    config_overrides: Optional[forecastClientConfig] = None,
    data_source: Optional["capo_forecast.types.data_source.DataSource"] = None,
    schema: Optional["capo_forecast.types.schema.Schema"] = None,
    enable_visualization: Optional["capo_forecast.types.boolean.Boolean"] = None,
    start_date_time: Optional[
        "capo_forecast.types.local_date_time.LocalDateTime"
    ] = None,
    end_date_time: Optional[
        "capo_forecast.types.local_date_time.LocalDateTime"
    ] = None,
    tags: Optional["capo_forecast.types.tags.Tags"] = None,
) -> "capo_forecast.types.create_explainability_response.CreateExplainabilityResponse":
    """<note> <p>Explainability is only available for Forecasts and Predictors generated from an AutoPredictor (<a>CreateAutoPredictor</a>)</p> </note> <p>Creates an Amazon Forecast Explainability.</p> <p>Explainability helps you better understand how the attributes in your datasets impact forecast. Amazon Forecast uses a metric called Impact scores to quantify the relative impact of each attribute and determine whether they increase or decrease forecast values.</p> <p>To enable Forecast Explainability, your predictor must include at least one of the following: related time series, item metadata, or additional datasets like Holidays and the Weather Index.</p> <p>CreateExplainability accepts either a Predictor ARN or Forecast ARN. To receive aggregated Impact scores for all time series and time points in your datasets, provide a Predictor ARN. To receive Impact scores for specific time series and time points, provide a Forecast ARN.</p> <p> <b>CreateExplainability with a Predictor ARN</b> </p> <note> <p>You can only have one Explainability resource per predictor. If you already enabled <code>ExplainPredictor</code> in <a>CreateAutoPredictor</a>, that predictor already has an Explainability resource.</p> </note> <p>The following parameters are required when providing a Predictor ARN:</p> <ul> <li> <p> <code>ExplainabilityName</code> - A unique name for the Explainability.</p> </li> <li> <p> <code>ResourceArn</code> - The Arn of the predictor.</p> </li> <li> <p> <code>TimePointGranularity</code> - Must be set to “ALL”.</p> </li> <li> <p> <code>TimeSeriesGranularity</code> - Must be set to “ALL”.</p> </li> </ul> <p>Do not specify a value for the following parameters:</p> <ul> <li> <p> <code>DataSource</code> - Only valid when TimeSeriesGranularity is “SPECIFIC”.</p> </li> <li> <p> <code>Schema</code> - Only valid when TimeSeriesGranularity is “SPECIFIC”.</p> </li> <li> <p> <code>StartDateTime</code> - Only valid when TimePointGranularity is “SPECIFIC”.</p> </li> <li> <p> <code>EndDateTime</code> - Only valid when TimePointGranularity is “SPECIFIC”.</p> </li> </ul> <p> <b>CreateExplainability with a Forecast ARN</b> </p> <note> <p>You can specify a maximum of 50 time series and 500 time points.</p> </note> <p>The following parameters are required when providing a Predictor ARN:</p> <ul> <li> <p> <code>ExplainabilityName</code> - A unique name for the Explainability.</p> </li> <li> <p> <code>ResourceArn</code> - The Arn of the forecast.</p> </li> <li> <p> <code>TimePointGranularity</code> - Either “ALL” or “SPECIFIC”.</p> </li> <li> <p> <code>TimeSeriesGranularity</code> - Either “ALL” or “SPECIFIC”.</p> </li> </ul> <p>If you set TimeSeriesGranularity to “SPECIFIC”, you must also provide the following:</p> <ul> <li> <p> <code>DataSource</code> - The S3 location of the CSV file specifying your time series.</p> </li> <li> <p> <code>Schema</code> - The Schema defines the attributes and attribute types listed in the Data Source.</p> </li> </ul> <p>If you set TimePointGranularity to “SPECIFIC”, you must also provide the following:</p> <ul> <li> <p> <code>StartDateTime</code> - The first timestamp in the range of time points.</p> </li> <li> <p> <code>EndDateTime</code> - The last timestamp in the range of time points.</p> </li> </ul>

    Args:
        explainability_name: <p>A unique name for the Explainability.</p>
        resource_arn: <p>The Amazon Resource Name (ARN) of the Predictor or Forecast used to create the Explainability.</p>
        explainability_config: <p>The configuration settings that define the granularity of time series and time points for the Explainability.</p>
        enable_visualization: <p>Create an Explainability visualization that is viewable within the Amazon Web Services console.</p>
        start_date_time: <p>If <code>TimePointGranularity</code> is set to <code>SPECIFIC</code>, define the first point for the Explainability.</p> <p>Use the following timestamp format: yyyy-MM-ddTHH:mm:ss (example: 2015-01-01T20:00:00)</p>
        end_date_time: <p>If <code>TimePointGranularity</code> is set to <code>SPECIFIC</code>, define the last time point for the Explainability.</p> <p>Use the following timestamp format: yyyy-MM-ddTHH:mm:ss (example: 2015-01-01T20:00:00)</p>
        tags: <p>Optional metadata to help you categorize and organize your resources. Each tag consists of a key and an optional value, both of which you define. Tag keys and values are case sensitive.</p> <p>The following restrictions apply to tags:</p> <ul> <li> <p>For each resource, each tag key must be unique and each tag key must have one value.</p> </li> <li> <p>Maximum number of tags per resource: 50.</p> </li> <li> <p>Maximum key length: 128 Unicode characters in UTF-8.</p> </li> <li> <p>Maximum value length: 256 Unicode characters in UTF-8.</p> </li> <li> <p>Accepted characters: all letters and numbers, spaces representable in UTF-8, and + - = . _ : / @. If your tagging schema is used across other services and resources, the character restrictions of those services also apply. </p> </li> <li> <p>Key prefixes cannot include any upper or lowercase combination of <code>aws:</code> or <code>AWS:</code>. Values can have this prefix. If a tag value has <code>aws</code> as its prefix but the key does not, Forecast considers it to be a user tag and will count against the limit of 50 tags. Tags with only the key prefix of <code>aws</code> do not count against your tags per resource limit. You cannot edit or delete tag keys with this prefix.</p> </li> </ul>

    Raises:
        capo_forecast.errors.invalid_input_exception.InvalidInputException: <p>We can't process the request because it includes an invalid value or a value that exceeds the valid range.</p>
        capo_forecast.errors.limit_exceeded_exception.LimitExceededException: <p>The limit on the number of resources per account has been exceeded.</p>
        capo_forecast.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>There is already a resource with this name. Try again with a different name.</p>
        capo_forecast.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource is in use.</p>
        capo_forecast.errors.resource_not_found_exception.ResourceNotFoundException: <p>We can't find a resource with that Amazon Resource Name (ARN). Check the ARN and try again.</p>
        capo_forecast.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_forecast.types.create_explainability_request.CreateExplainabilityRequest]",
    ) -> OperationResponse[
        "capo_forecast.types.create_explainability_response.CreateExplainabilityResponse"
    ]:
        import capo_forecast._operations.amazon_forecast.create_explainability

        output, http_response = (
            capo_forecast._operations.amazon_forecast.create_explainability.create_explainability(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_forecast.types.create_explainability_request.CreateExplainabilityRequest",
    ) -> dict[str, Any]:
        import capo_forecast.types.create_explainability_request

        return capo_forecast.types.create_explainability_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateExplainability", redact_input=_redact_input),
    )
    input_: capo_forecast.types.create_explainability_request.CreateExplainabilityRequest = {
        "explainability_name": explainability_name,
        "resource_arn": resource_arn,
        "explainability_config": explainability_config,
    }
    if data_source is not None:
        input_["data_source"] = data_source
    if schema is not None:
        input_["schema"] = schema
    if enable_visualization is not None:
        input_["enable_visualization"] = enable_visualization
    if start_date_time is not None:
        input_["start_date_time"] = start_date_time
    if end_date_time is not None:
        input_["end_date_time"] = end_date_time
    if tags is not None:
        input_["tags"] = tags

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