Skip to content

create_what_if_analysis async

create_what_if_analysis(
    what_if_analysis_name: Name,
    forecast_arn: Arn,
    *,
    config_overrides: Optional[AsyncforecastClientConfig] = None,
    time_series_selector: Optional[TimeSeriesSelector] = None,
    tags: Optional[Tags] = None,
) -> CreateWhatIfAnalysisResponse

What-if analysis is a scenario modeling technique where you make a hypothetical change to a time series and compare the forecasts generated by these changes against the baseline, unchanged time series. It is important to remember that the purpose of a what-if analysis is to understand how a forecast can change given different modifications to the baseline time series.

For example, imagine you are a clothing retailer who is considering an end of season sale to clear space for new styles. After creating a baseline forecast, you can use a what-if analysis to investigate how different sales tactics might affect your goals.

You could create a scenario where everything is given a 25% markdown, and another where everything is given a fixed dollar markdown. You could create a scenario where the sale lasts for one week and another where the sale lasts for one month. With a what-if analysis, you can compare many different scenarios against each other.

Note that a what-if analysis is meant to display what the forecasting model has learned and how it will behave in the scenarios that you are evaluating. Do not blindly use the results of the what-if analysis to make business decisions. For instance, forecasts might not be accurate for novel scenarios where there is no reference available to determine whether a forecast is good.

The TimeSeriesSelector object defines the items that you want in the what-if analysis.

Parameters:

  • what_if_analysis_name (Name) –

    The name of the what-if analysis. Each name must be unique.

  • forecast_arn (Arn) –

    The Amazon Resource Name (ARN) of the baseline forecast.

  • time_series_selector (Optional[TimeSeriesSelector], default: None ) –

    Defines the set of time series that are used in the what-if analysis with a TimeSeriesIdentifiers object. What-if analyses are performed only for the time series in this object.

    The TimeSeriesIdentifiers object needs the following information:

    • DataSource

    • Format

    • Schema

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

    A list of tags to apply to the what if forecast.

Raises:

Source code in docs_src/capo_forecast/_services/async_forecast.py
async def create_what_if_analysis(
    self,
    what_if_analysis_name: "capo_forecast.types.name.Name",
    forecast_arn: "capo_forecast.types.arn.Arn",
    *,
    config_overrides: Optional[AsyncforecastClientConfig] = None,
    time_series_selector: Optional[
        "capo_forecast.types.time_series_selector.TimeSeriesSelector"
    ] = None,
    tags: Optional["capo_forecast.types.tags.Tags"] = None,
) -> "capo_forecast.types.create_what_if_analysis_response.CreateWhatIfAnalysisResponse":
    """<p>What-if analysis is a scenario modeling technique where you make a hypothetical change to a time series and compare the forecasts generated by these changes against the baseline, unchanged time series. It is important to remember that the purpose of a what-if analysis is to understand how a forecast can change given different modifications to the baseline time series.</p> <p>For example, imagine you are a clothing retailer who is considering an end of season sale to clear space for new styles. After creating a baseline forecast, you can use a what-if analysis to investigate how different sales tactics might affect your goals.</p> <p>You could create a scenario where everything is given a 25% markdown, and another where everything is given a fixed dollar markdown. You could create a scenario where the sale lasts for one week and another where the sale lasts for one month. With a what-if analysis, you can compare many different scenarios against each other.</p> <p>Note that a what-if analysis is meant to display what the forecasting model has learned and how it will behave in the scenarios that you are evaluating. Do not blindly use the results of the what-if analysis to make business decisions. For instance, forecasts might not be accurate for novel scenarios where there is no reference available to determine whether a forecast is good.</p> <p>The <a>TimeSeriesSelector</a> object defines the items that you want in the what-if analysis.</p>

    Args:
        what_if_analysis_name: <p>The name of the what-if analysis. Each name must be unique.</p>
        forecast_arn: <p>The Amazon Resource Name (ARN) of the baseline forecast.</p>
        time_series_selector: <p>Defines the set of time series that are used in the what-if analysis with a <code>TimeSeriesIdentifiers</code> object. What-if analyses are performed only for the time series in this object.</p> <p>The <code>TimeSeriesIdentifiers</code> object needs the following information:</p> <ul> <li> <p> <code>DataSource</code> </p> </li> <li> <p> <code>Format</code> </p> </li> <li> <p> <code>Schema</code> </p> </li> </ul>
        tags: <p>A list of <a href="https://docs.aws.amazon.com/forecast/latest/dg/tagging-forecast-resources.html">tags</a> to apply to the what if forecast.</p>

    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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_forecast.types.create_what_if_analysis_request.CreateWhatIfAnalysisRequest]",
    ) -> AsyncOperationResponse[
        "capo_forecast.types.create_what_if_analysis_response.CreateWhatIfAnalysisResponse"
    ]:
        import capo_forecast._operations.amazon_forecast.create_what_if_analysis

        (
            output,
            http_response,
        ) = await capo_forecast._operations.amazon_forecast.create_what_if_analysis.async_create_what_if_analysis(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

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

        return capo_forecast.types.create_what_if_analysis_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateWhatIfAnalysis", redact_input=_redact_input),
    )
    input_: capo_forecast.types.create_what_if_analysis_request.CreateWhatIfAnalysisRequest = {
        "what_if_analysis_name": what_if_analysis_name,
        "forecast_arn": forecast_arn,
    }
    if time_series_selector is not None:
        input_["time_series_selector"] = time_series_selector
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output